Same filename and directory in other branches
- 8.9.x core/lib/Drupal/Core/Routing/RouteProviderLazyBuilder.php
- 9 core/lib/Drupal/Core/Routing/RouteProviderLazyBuilder.php
Namespace
Drupal\Core\Routing
File
core/lib/Drupal/Core/Routing/RouteProviderLazyBuilder.php
View source
<?php
namespace Drupal\Core\Routing;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\Request;
class RouteProviderLazyBuilder implements PreloadableRouteProviderInterface, EventSubscriberInterface {
protected $routeProvider;
protected $routeBuilder;
protected $rebuilt = FALSE;
protected $rebuilding = FALSE;
public function __construct(RouteProviderInterface $route_provider, RouteBuilderInterface $route_builder) {
$this->routeProvider = $route_provider;
$this->routeBuilder = $route_builder;
}
protected function getRouteProvider() {
if (!$this->rebuilt && !$this->rebuilding) {
$this->routeBuilder
->rebuild();
}
return $this->routeProvider;
}
public function getRouteCollectionForRequest(Request $request) {
return $this
->getRouteProvider()
->getRouteCollectionForRequest($request);
}
public function getRouteByName($name) {
return $this
->getRouteProvider()
->getRouteByName($name);
}
public function preLoadRoutes($names) {
return $this
->getRouteProvider()
->preLoadRoutes($names);
}
public function getRoutesByNames($names) {
return $this
->getRouteProvider()
->getRoutesByNames($names);
}
public function getRoutesByPattern($pattern) {
return $this
->getRouteProvider()
->getRoutesByPattern($pattern);
}
public function getAllRoutes() {
return $this
->getRouteProvider()
->getAllRoutes();
}
public function reset() {
return $this->routeProvider
->reset();
}
public function hasRebuilt() {
return $this->rebuilt;
}
public static function getSubscribedEvents() : array {
$events[RoutingEvents::DYNAMIC][] = [
'routerRebuilding',
3000,
];
$events[RoutingEvents::FINISHED][] = [
'routerRebuildFinished',
-3000,
];
return $events;
}
public function routerRebuilding() {
$this->rebuilding = TRUE;
}
public function routerRebuildFinished() {
$this->rebuilding = FALSE;
$this->rebuilt = TRUE;
}
}
Classes