if ($bundle_entity_type_id) { $bundle_argument =
$bundle_entity_type_id;
$bundle_entity_type =
$this->entityTypeManager->
getDefinition($bundle_entity_type_id);
$bundle_entity_type_label =
$bundle_entity_type->
getSingularLabel();
$build['#cache'
]['tags'
] =
$bundle_entity_type->
getListCacheTags();
// Build the message shown when there are no bundles.
$link_text =
$this->
t('Add a new @entity_type.',
['@entity_type' =>
$bundle_entity_type_label]);
$link_route_name = 'entity.' .
$bundle_entity_type->
id() . '.add_form';
$build['#add_bundle_message'
] =
$this->
t('There is no @entity_type yet. @add_link',
[ '@entity_type' =>
$bundle_entity_type_label,
'@add_link' => Link::
createFromRoute($link_text,
$link_route_name)->
toString(),
]);
// Filter out the bundles the user doesn't have access to.
$access_control_handler =
$this->entityTypeManager->
getAccessControlHandler($entity_type_id);
foreach ($bundles as $bundle_name =>
$bundle_info) { $access =
$access_control_handler->
createAccess($bundle_name, NULL,
[], TRUE
);
if (!
$access->
isAllowed()) { unset($bundles[$bundle_name]);
} $this->renderer->
addCacheableDependency($build,
$access);
} // Add descriptions from the bundle entities.