function RoutePreloader::onAlterRoutes

Same name in other branches
  1. 9 core/lib/Drupal/Core/Routing/RoutePreloader.php \Drupal\Core\Routing\RoutePreloader::onAlterRoutes()
  2. 8.9.x core/lib/Drupal/Core/Routing/RoutePreloader.php \Drupal\Core\Routing\RoutePreloader::onAlterRoutes()
  3. 10 core/lib/Drupal/Core/Routing/RoutePreloader.php \Drupal\Core\Routing\RoutePreloader::onAlterRoutes()

Alters existing routes for a specific collection.

Parameters

\Drupal\Core\Routing\RouteBuildEvent $event: The route build event.

File

core/lib/Drupal/Core/Routing/RoutePreloader.php, line 65

Class

RoutePreloader
Defines a class that can pre-load non-admin routes.

Namespace

Drupal\Core\Routing

Code

public function onAlterRoutes(RouteBuildEvent $event) {
    $collection = $event->getRouteCollection();
    foreach ($collection->all() as $name => $route) {
        if (!str_starts_with($route->getPath(), '/admin/') && $route->getPath() != '/admin' && static::isGetAndHtmlRoute($route)) {
            $this->nonAdminRoutesOnRebuild[] = $name;
        }
    }
    $this->nonAdminRoutesOnRebuild = array_unique($this->nonAdminRoutesOnRebuild);
}

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