You are here

protected function NodeAdminRouteSubscriber::alterRoutes in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/node/src/EventSubscriber/NodeAdminRouteSubscriber.php \Drupal\node\EventSubscriber\NodeAdminRouteSubscriber::alterRoutes()
  2. 9 core/modules/node/src/EventSubscriber/NodeAdminRouteSubscriber.php \Drupal\node\EventSubscriber\NodeAdminRouteSubscriber::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);
      }
    }
  }
}