You are here

protected function GroupContentMenuRouteProvider::getCollectionRoute in Group Content Menu 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/GroupContentMenuRouteProvider.php, line 129

Class

GroupContentMenuRouteProvider
Provides routes for group_content_menu content.

Namespace

Drupal\group_content_menu\Routing

Code

protected function getCollectionRoute(EntityTypeInterface $entity_type) {
  if ($entity_type
    ->hasLinkTemplate('collection') && $entity_type
    ->hasListBuilderClass()) {

    /** @var \Drupal\Core\StringTranslation\TranslatableMarkup $label */
    $label = $entity_type
      ->getCollectionLabel();
    $route = new Route($entity_type
      ->getLinkTemplate('collection'));
    return $route
      ->addDefaults([
      '_entity_list' => $entity_type
        ->id(),
      '_title' => $label
        ->getUntranslatedString(),
      '_title_arguments' => $label
        ->getArguments(),
      '_title_context' => $label
        ->getOption('context'),
    ])
      ->setOption('_group_operation_route', TRUE)
      ->setRequirement('_group_permission', 'access group content menu overview')
      ->setOption('parameters', [
      'group' => [
        'type' => 'entity:group',
      ],
    ]);
  }
}