You are here

protected function AdminRouteSubscriber::alterRoutes in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 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 22
Contains \Drupal\system\EventSubscriber\AdminRouteSubscriber.

Class

AdminRouteSubscriber
Adds the _admin_route option to each admin route.

Namespace

Drupal\system\EventSubscriber

Code

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);
    }
  }
}