public function PathRootsSubscriber::onRouteAlter in Zircon Profile 8
Same name and namespace in other branches
- 8.0 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 53 - Contains \Drupal\Core\EventSubscriber\PathRootsSubscriber.
Class
- PathRootsSubscriber
- Provides all available first bits of all route paths.
Namespace
Drupal\Core\EventSubscriberCode
public function onRouteAlter(RouteBuildEvent $event) {
$collection = $event
->getRouteCollection();
foreach ($collection
->all() as $route) {
$bits = explode('/', ltrim($route
->getPath(), '/'));
$this->pathRoots[$bits[0]] = $bits[0];
}
}