function DefaultHtmlRouteProvider::getCollectionRoute
Same name in other branches
- 9 core/lib/Drupal/Core/Entity/Routing/DefaultHtmlRouteProvider.php \Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider::getCollectionRoute()
- 8.9.x core/lib/Drupal/Core/Entity/Routing/DefaultHtmlRouteProvider.php \Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider::getCollectionRoute()
- 11.x core/lib/Drupal/Core/Entity/Routing/DefaultHtmlRouteProvider.php \Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider::getCollectionRoute()
Gets the collection route.
Parameters
\Drupal\Core\Entity\EntityTypeInterface $entity_type: The entity type.
Return value
\Symfony\Component\Routing\Route|null The generated route, if available.
1 call to DefaultHtmlRouteProvider::getCollectionRoute()
- DefaultHtmlRouteProvider::getRoutes in core/
lib/ Drupal/ Core/ Entity/ Routing/ DefaultHtmlRouteProvider.php - Provides routes for entities.
1 method overrides DefaultHtmlRouteProvider::getCollectionRoute()
- TestDefaultHtmlRouteProvider::getCollectionRoute in core/
tests/ Drupal/ Tests/ Core/ Entity/ Routing/ DefaultHtmlRouteProviderTest.php - Gets the collection route.
File
-
core/
lib/ Drupal/ Core/ Entity/ Routing/ DefaultHtmlRouteProvider.php, line 318
Class
- DefaultHtmlRouteProvider
- Provides HTML routes for entities.
Namespace
Drupal\Core\Entity\RoutingCode
protected function getCollectionRoute(EntityTypeInterface $entity_type) {
// If the entity type does not provide either an admin or collection
// permission, there is no way to control access, so we cannot provide
// a route in a sensible way.
$permissions = array_filter([
$entity_type->getAdminPermission(),
$entity_type->getCollectionPermission(),
]);
if ($entity_type->hasLinkTemplate('collection') && $entity_type->hasListBuilderClass() && $permissions) {
/** @var \Drupal\Core\StringTranslation\TranslatableMarkup $label */
$label = $entity_type->getCollectionLabel();
$route = new Route($entity_type->getLinkTemplate('collection'));
$route->addDefaults([
'_entity_list' => $entity_type->id(),
'_title' => $label->getUntranslatedString(),
'_title_arguments' => $label->getArguments(),
'_title_context' => $label->getOption('context'),
])
->setRequirement('_permission', implode('+', $permissions));
return $route;
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.