function PathRootsSubscriber::onRouteAlter

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/EventSubscriber/PathRootsSubscriber.php \Drupal\Core\EventSubscriber\PathRootsSubscriber::onRouteAlter()
  2. 8.9.x core/lib/Drupal/Core/EventSubscriber/PathRootsSubscriber.php \Drupal\Core\EventSubscriber\PathRootsSubscriber::onRouteAlter()
  3. 11.x core/lib/Drupal/Core/EventSubscriber/PathRootsSubscriber.php \Drupal\Core\EventSubscriber\PathRootsSubscriber::onRouteAlter()

Collects all path roots.

Parameters

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

File

core/lib/Drupal/Core/EventSubscriber/PathRootsSubscriber.php, line 48

Class

PathRootsSubscriber
Provides all available first bits of all route paths.

Namespace

Drupal\Core\EventSubscriber

Code

public function onRouteAlter(RouteBuildEvent $event) {
  $collection = $event->getRouteCollection();
  foreach ($collection->all() as $route) {
    $bits = explode('/', ltrim($route->getPath(), '/'));
    $this->pathRoots[$bits[0]] = $bits[0];
  }
}

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