3 namespace Drupal\simpletest;
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 * @todo Move this outside of simpletest namespace to the Drupal\Tests, see
13 * https://www.drupal.org/node/2672762
15 class RouteProvider implements PreloadableRouteProviderInterface, PagedRouteProviderInterface {
17 use \Drupal\Core\DependencyInjection\DependencySerializationTrait;
20 * Loads the real route provider from the container and rebuilds the router.
22 * @return \Drupal\Core\Routing\PreloadableRouteProviderInterface|\Symfony\Cmf\Component\Routing\PagedRouteProviderInterface|\Symfony\Component\EventDispatcher\EventSubscriberInterface
25 protected function lazyLoadItself() {
26 if (!isset($this->service)) {
27 $container = \Drupal::getContainer();
28 $this->service = $container->get('simpletest.router.route_provider');
29 $container->get('router.builder')->rebuild();
32 return $this->service;
38 public function getRouteCollectionForRequest(Request $request) {
39 return $this->lazyLoadItself()->getRouteCollectionForRequest($request);
45 public function getRouteByName($name) {
46 return $this->lazyLoadItself()->getRouteByName($name);
52 public function preLoadRoutes($names) {
53 return $this->lazyLoadItself()->preLoadRoutes($names);
59 public function getRoutesByNames($names) {
60 return $this->lazyLoadItself()->getRoutesByNames($names);
66 public function getCandidateOutlines(array $parts) {
67 return $this->lazyLoadItself()->getCandidateOutlines($parts);
73 public function getRoutesByPattern($pattern) {
74 return $this->lazyLoadItself()->getRoutesByPattern($pattern);
80 public function routeProviderRouteCompare(array $a, array $b) {
81 return $this->lazyLoadItself()->routeProviderRouteCompare($a, $b);
87 public function getAllRoutes() {
88 return $this->lazyLoadItself()->getAllRoutes();
94 public function reset() {
95 return $this->lazyLoadItself()->reset();
101 public function getRoutesPaged($offset, $length = NULL) {
102 return $this->lazyLoadItself()->getRoutesPaged($offset, $length);
108 public function getRoutesCount() {
109 return $this->lazyLoadItself()->getRoutesCount();