RoutePreloader::onAlterRoutes

public RoutePreloader::onAlterRoutes(RouteBuildEvent $event)

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 99

Class

RoutePreloader
Defines a class which preloads non-admin routes.

Namespace

Drupal\Core\Routing

Code

public function onAlterRoutes(RouteBuildEvent $event) {
  $collection = $event->getRouteCollection();
  foreach ($collection->all() as $name => $route) {
    if (strpos($route->getPath(), '/admin/') !== 0 && $route->getPath() != '/admin') {
      $this->nonAdminRoutesOnRebuild[] = $name;
    }
  }
  $this->nonAdminRoutesOnRebuild = array_unique($this->nonAdminRoutesOnRebuild);
}
doc_Drupal
2016-10-29 09:39:10
Comments
Leave a Comment

Please login to continue.