You are here

protected function DefaultHtmlRouteProvider::getCollectionRoute in Entity API 8

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.

Overrides DefaultHtmlRouteProvider::getCollectionRoute

File

src/Routing/DefaultHtmlRouteProvider.php, line 32

Class

DefaultHtmlRouteProvider
Provides HTML routes for entities.

Namespace

Drupal\entity\Routing

Code

protected function getCollectionRoute(EntityTypeInterface $entity_type) {
  $route = parent::getCollectionRoute($entity_type);
  if ($route && $entity_type
    ->hasHandlerClass('permission_provider')) {
    $admin_permission = $entity_type
      ->getAdminPermission();
    $overview_permission = "access {$entity_type->id()} overview";
    $route
      ->setRequirement('_permission', "{$admin_permission}+{$overview_permission}");
  }
  return $route;
}