class AccessRouteAlterSubscriber
Same name in other branches
- 10 core/modules/system/src/EventSubscriber/AccessRouteAlterSubscriber.php \Drupal\system\EventSubscriber\AccessRouteAlterSubscriber
Alters routes to add necessary requirements.
Hierarchy
- class \Drupal\system\EventSubscriber\AccessRouteAlterSubscriber implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
Expanded class hierarchy of AccessRouteAlterSubscriber
See also
\Drupal\system\Access\SystemAdminMenuBlockAccessCheck
\Drupal\system\Controller\SystemController::systemAdminMenuBlockPage()
1 string reference to 'AccessRouteAlterSubscriber'
- system.services.yml in core/
modules/ system/ system.services.yml - core/modules/system/system.services.yml
1 service uses AccessRouteAlterSubscriber
File
-
core/
modules/ system/ src/ EventSubscriber/ AccessRouteAlterSubscriber.php, line 15
Namespace
Drupal\system\EventSubscriberView source
class AccessRouteAlterSubscriber implements EventSubscriberInterface {
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() : array {
$events[RoutingEvents::ALTER][] = 'accessAdminMenuBlockPage';
return $events;
}
/**
* Adds _access_admin_menu_block_page requirement to routes pointing to SystemController::systemAdminMenuBlockPage.
*
* @param \Drupal\Core\Routing\RouteBuildEvent $event
* The event to process.
*/
public function accessAdminMenuBlockPage(RouteBuildEvent $event) {
$routes = $event->getRouteCollection();
foreach ($routes as $route) {
// Do not use a leading slash when comparing to the _controller string
// because the leading slash in a fully-qualified method name is optional.
if ($route->hasDefault('_controller')) {
switch (ltrim($route->getDefault('_controller'), '\\')) {
case 'Drupal\\system\\Controller\\SystemController::systemAdminMenuBlockPage':
$route->setRequirement('_access_admin_menu_block_page', 'TRUE');
break;
case 'Drupal\\system\\Controller\\SystemController::overview':
$route->setRequirement('_access_admin_overview_page', 'TRUE');
break;
}
}
}
}
}
Members
Title Sort descending | Modifiers | Object type | Summary |
---|---|---|---|
AccessRouteAlterSubscriber::accessAdminMenuBlockPage | public | function | Adds _access_admin_menu_block_page requirement to routes pointing to SystemController::systemAdminMenuBlockPage. |
AccessRouteAlterSubscriber::getSubscribedEvents | public static | function |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.