DefaultHtmlRouteProvider::getCollectionRoute

protected DefaultHtmlRouteProvider::getCollectionRoute(EntityTypeInterface $entity_type)

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.

File

core/lib/Drupal/Core/Entity/Routing/DefaultHtmlRouteProvider.php, line 315

Class

DefaultHtmlRouteProvider
Provides HTML routes for entities.

Namespace

Drupal\Core\Entity\Routing

Code

protected function getCollectionRoute(EntityTypeInterface $entity_type) {
  // If the entity type does not provide an admin permission, there is no way
  // to control access, so we cannot provide a route in a sensible way.
  if ($entity_type->hasLinkTemplate('collection') && $entity_type->hasListBuilderClass() && ($admin_permission = $entity_type->getAdminPermission())) {
    $route = new Route($entity_type->getLinkTemplate('collection'));
    $route
    ->addDefaults([
      '_entity_list' => $entity_type->id(),
      // @todo Improve this in https://www.drupal.org/node/2767025
      '_title' => '@label entities',
      '_title_arguments' => ['@label' => $entity_type->getLabel()],
    ])
      ->setRequirement('_permission', $admin_permission);

    return $route;
  }
}
doc_Drupal
2016-10-29 09:01:43
Comments
Leave a Comment

Please login to continue.