class RouteSubscriber in Menu Admin per Menu 8
Listens to the dynamic route events.
Hierarchy
- class \Drupal\Core\Routing\RouteSubscriberBase implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
- class \Drupal\menu_admin_per_menu\Routing\RouteSubscriber
Expanded class hierarchy of RouteSubscriber
1 string reference to 'RouteSubscriber'
1 service uses RouteSubscriber
File
- src/
Routing/ RouteSubscriber.php, line 12
Namespace
Drupal\menu_admin_per_menu\RoutingView source
class RouteSubscriber extends RouteSubscriberBase {
/**
* {@inheritdoc}
*/
protected function alterRoutes(RouteCollection $collection) {
$routes = $collection
->all();
foreach ($routes as $route_name => $route) {
switch ($route_name) {
case 'entity.menu.collection':
$route
->setDefaults([
'_title' => $route
->getDefault('_title'),
'_controller' => '\\Drupal\\menu_admin_per_menu\\Controller\\MenuAdminPerMenuController::menuOverviewPage',
]);
$route
->setRequirements([
'_custom_access' => '\\Drupal\\menu_admin_per_menu\\Access\\MenuAdminPerMenuAccess::menusOverviewAccess',
]);
break;
case 'entity.menu.edit_form':
case 'entity.menu.add_link_form':
$route
->setRequirements([
'_custom_access' => '\\Drupal\\menu_admin_per_menu\\Access\\MenuAdminPerMenuAccess::menuAccess',
]);
break;
case 'menu_ui.link_edit':
case 'menu_ui.link_reset':
$route
->setRequirements([
'_custom_access' => '\\Drupal\\menu_admin_per_menu\\Access\\MenuAdminPerMenuAccess::menuLinkAccess',
]);
break;
case 'entity.menu_link_content.canonical':
case 'entity.menu_link_content.delete_form':
case 'entity.menu_link_content.content_translation_overview':
case 'entity.menu_link_content.content_translation_add':
case 'entity.menu_link_content.content_translation_edit':
case 'entity.menu_link_content.content_translation_delete':
$route
->setRequirements([
'_custom_access' => '\\Drupal\\menu_admin_per_menu\\Access\\MenuAdminPerMenuAccess::menuItemAccess',
]);
break;
}
}
}
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
// Run after content_translation, which has priority -210.
$events[RoutingEvents::ALTER] = [
'onAlterRoutes',
-220,
];
return $events;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
RouteSubscriber:: |
protected | function |
Alters existing routes for a specific collection. Overrides RouteSubscriberBase:: |
|
RouteSubscriber:: |
public static | function |
Returns an array of event names this subscriber wants to listen to. Overrides RouteSubscriberBase:: |
|
RouteSubscriberBase:: |
public | function | Delegates the route altering to self::alterRoutes(). | 1 |