You are here

protected function GroupContentMenuRouteProvider::getAddMenuLink in Group Content Menu 8

Gets the add-menu-link 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 GroupContentMenuRouteProvider::getAddMenuLink()
GroupContentMenuRouteProvider::getRoutes in src/Routing/GroupContentMenuRouteProvider.php
Provides routes for entities.

File

src/Routing/GroupContentMenuRouteProvider.php, line 41

Class

GroupContentMenuRouteProvider
Provides routes for group_content_menu content.

Namespace

Drupal\group_content_menu\Routing

Code

protected function getAddMenuLink(EntityTypeInterface $entity_type) {
  if ($entity_type
    ->hasLinkTemplate('add-menu-link')) {
    $route = new Route($entity_type
      ->getLinkTemplate('add-menu-link'));
    return $route
      ->setDefaults([
      '_title' => 'Add menu link',
      '_controller' => sprintf('%s::addLink', GroupContentMenuController::class),
    ])
      ->setRequirement('_group_permission', implode('+', $this
      ->getCreatePermissions()))
      ->setRequirement('_group_installed_content', implode('+', $this
      ->getPluginIds()))
      ->setOption('parameters', [
      'group' => [
        'type' => 'entity:group',
      ],
      'group_content_menu' => [
        'type' => 'entity:group_content_menu',
      ],
    ])
      ->setOption('_group_operation_route', TRUE);
  }
}