class AdminRouteSubscriber in Zircon Profile 8.0
Same name and namespace in other branches
- 8 core/modules/system/src/EventSubscriber/AdminRouteSubscriber.php \Drupal\system\EventSubscriber\AdminRouteSubscriber
Adds the _admin_route option to each admin route.
Hierarchy
- class \Drupal\Core\Routing\RouteSubscriberBase implements EventSubscriberInterface
- class \Drupal\system\EventSubscriber\AdminRouteSubscriber
Expanded class hierarchy of AdminRouteSubscriber
1 string reference to 'AdminRouteSubscriber'
- system.services.yml in core/
modules/ system/ system.services.yml - core/modules/system/system.services.yml
1 service uses AdminRouteSubscriber
File
- core/
modules/ system/ src/ EventSubscriber/ AdminRouteSubscriber.php, line 17 - Contains \Drupal\system\EventSubscriber\AdminRouteSubscriber.
Namespace
Drupal\system\EventSubscriberView source
class AdminRouteSubscriber extends RouteSubscriberBase {
/**
* {@inheritdoc}
*/
protected function alterRoutes(RouteCollection $collection) {
foreach ($collection
->all() as $route) {
if (strpos($route
->getPath(), '/admin') === 0 && !$route
->hasOption('_admin_route')) {
$route
->setOption('_admin_route', TRUE);
}
}
}
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
$events = parent::getSubscribedEvents();
// Use a higher priority than \Drupal\field_ui\Routing\RouteSubscriber or
// \Drupal\views\EventSubscriber\RouteSubscriber to ensure we add the
// option to their routes.
// @todo https://www.drupal.org/node/2158571
$events[RoutingEvents::ALTER] = array(
'onAlterRoutes',
-200,
);
return $events;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
AdminRouteSubscriber:: |
protected | function |
Alters existing routes for a specific collection. Overrides RouteSubscriberBase:: |
|
AdminRouteSubscriber:: |
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 |