3 namespace Drupal\KernelTests;
5 use Drupal\Core\Routing\PreloadableRouteProviderInterface;
6 use Symfony\Cmf\Component\Routing\PagedRouteProviderInterface;
7 use Symfony\Component\HttpFoundation\Request;
10 * Rebuilds the router when the provider is instantiated.
12 class RouteProvider implements PreloadableRouteProviderInterface, PagedRouteProviderInterface {
14 use \Drupal\Core\DependencyInjection\DependencySerializationTrait;
17 * Loads the real route provider from the container and rebuilds the router.
19 * @return \Drupal\Core\Routing\PreloadableRouteProviderInterface|\Symfony\Cmf\Component\Routing\PagedRouteProviderInterface|\Symfony\Component\EventDispatcher\EventSubscriberInterface
22 protected function lazyLoadItself() {
23 if (!isset($this->service)) {
24 $container = \Drupal::getContainer();
25 $this->service = $container->get('simpletest.router.route_provider');
26 $container->get('router.builder')->rebuild();
29 return $this->service;
35 public function getRouteCollectionForRequest(Request $request) {
36 return $this->lazyLoadItself()->getRouteCollectionForRequest($request);
42 public function getRouteByName($name) {
43 return $this->lazyLoadItself()->getRouteByName($name);
49 public function preLoadRoutes($names) {
50 return $this->lazyLoadItself()->preLoadRoutes($names);
56 public function getRoutesByNames($names) {
57 return $this->lazyLoadItself()->getRoutesByNames($names);
63 public function getCandidateOutlines(array $parts) {
64 return $this->lazyLoadItself()->getCandidateOutlines($parts);
70 public function getRoutesByPattern($pattern) {
71 return $this->lazyLoadItself()->getRoutesByPattern($pattern);
77 public function routeProviderRouteCompare(array $a, array $b) {
78 return $this->lazyLoadItself()->routeProviderRouteCompare($a, $b);
84 public function getAllRoutes() {
85 return $this->lazyLoadItself()->getAllRoutes();
91 public function reset() {
92 return $this->lazyLoadItself()->reset();
98 public function getRoutesPaged($offset, $length = NULL) {
99 return $this->lazyLoadItself()->getRoutesPaged($offset, $length);
105 public function getRoutesCount() {
106 return $this->lazyLoadItself()->getRoutesCount();