protected function GroupMenuRouteSubscriber::alterRoutes in Group Menu 8
Alters existing routes for a specific collection.
Parameters
\Symfony\Component\Routing\RouteCollection $collection: The route collection for adding routes.
Overrides RouteSubscriberBase::alterRoutes
File
- src/
Routing/ GroupMenuRouteSubscriber.php, line 16
Class
- GroupMenuRouteSubscriber
- Modify form for config.sync route.
Namespace
Drupal\groupmenu\RoutingCode
protected function alterRoutes(RouteCollection $collection) {
$routes = $collection
->all();
foreach ($routes as $route_name => $route) {
switch ($route_name) {
case 'entity.menu.edit_form':
case 'entity.menu.add_link_form':
$route
->setRequirements([
'_custom_access' => '\\Drupal\\groupmenu\\Access\\GroupMenuAccess::menuEditAccess',
]);
break;
case 'entity.menu.delete_form':
$route
->setRequirements([
'_custom_access' => '\\Drupal\\groupmenu\\Access\\GroupMenuAccess::menuDeleteAccess',
]);
break;
case 'menu_ui.link_edit':
case 'menu_ui.link_reset':
$route
->setRequirements([
'_custom_access' => '\\Drupal\\groupmenu\\Access\\GroupMenuAccess::menuLinkAccess',
]);
break;
case 'entity.menu_link_content.canonical':
case 'entity.menu_link_content.delete_form':
$route
->setRequirements([
'_custom_access' => '\\Drupal\\groupmenu\\Access\\GroupMenuAccess::menuItemAccess',
]);
break;
}
}
}