You are here

protected function GroupContentRouteProvider::getCollectionRoute in Group 2.0.x

Same name and namespace in other branches
  1. 8 src/Entity/Routing/GroupContentRouteProvider.php \Drupal\group\Entity\Routing\GroupContentRouteProvider::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.

Overrides DefaultHtmlRouteProvider::getCollectionRoute

File

src/Entity/Routing/GroupContentRouteProvider.php, line 123

Class

GroupContentRouteProvider
Provides routes for group content.

Namespace

Drupal\group\Entity\Routing

Code

protected function getCollectionRoute(EntityTypeInterface $entity_type) {
  if ($entity_type
    ->hasLinkTemplate('collection') && $entity_type
    ->hasListBuilderClass()) {
    $route = new Route($entity_type
      ->getLinkTemplate('collection'));
    $route
      ->addDefaults([
      '_entity_list' => 'group_content',
      '_title_callback' => '\\Drupal\\group\\Entity\\Controller\\GroupContentController::collectionTitle',
    ])
      ->setRequirement('_group_permission', "access content overview")
      ->setOption('_group_operation_route', TRUE)
      ->setOption('parameters', [
      'group' => [
        'type' => 'entity:group',
      ],
    ]);
    return $route;
  }
}