function NodeAdminRouteSubscriber::alterRoutes

Same name in other branches
  1. 9 core/modules/node/src/EventSubscriber/NodeAdminRouteSubscriber.php \Drupal\node\EventSubscriber\NodeAdminRouteSubscriber::alterRoutes()
  2. 8.9.x core/modules/node/src/EventSubscriber/NodeAdminRouteSubscriber.php \Drupal\node\EventSubscriber\NodeAdminRouteSubscriber::alterRoutes()
  3. 11.x core/modules/node/src/EventSubscriber/NodeAdminRouteSubscriber.php \Drupal\node\EventSubscriber\NodeAdminRouteSubscriber::alterRoutes()

Overrides RouteSubscriberBase::alterRoutes

File

core/modules/node/src/EventSubscriber/NodeAdminRouteSubscriber.php, line 47

Class

NodeAdminRouteSubscriber
Sets the _admin_route for specific node-related routes.

Namespace

Drupal\node\EventSubscriber

Code

protected function alterRoutes(RouteCollection $collection) {
    if ($this->configFactory
        ->get('node.settings')
        ->get('use_admin_theme')) {
        foreach ($collection->all() as $route) {
            if ($route->hasOption('_node_operation_route')) {
                $route->setOption('_admin_route', TRUE);
            }
        }
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.