protected function AdminRouteSubscriber::alterRoutes in Drupal 8
Same name and namespace in other branches
- 9 core/modules/system/src/EventSubscriber/AdminRouteSubscriber.php \Drupal\system\EventSubscriber\AdminRouteSubscriber::alterRoutes()
Alters existing routes for a specific collection.
Parameters
\Symfony\Component\Routing\RouteCollection $collection: The route collection for adding routes.
Overrides RouteSubscriberBase::alterRoutes
File
- core/
modules/ system/ src/ EventSubscriber/ AdminRouteSubscriber.php, line 18
Class
- AdminRouteSubscriber
- Adds the _admin_route option to each admin HTML route.
Namespace
Drupal\system\EventSubscriberCode
protected function alterRoutes(RouteCollection $collection) {
foreach ($collection
->all() as $route) {
$path = $route
->getPath();
if (($path == '/admin' || strpos($path, '/admin/') === 0) && !$route
->hasOption('_admin_route') && static::isHtmlRoute($route)) {
$route
->setOption('_admin_route', TRUE);
}
}
}