comparison core/modules/simpletest/src/RouteProvider.php @ 17:129ea1e6d783

Update, including to Drupal core 8.6.10
author Chris Cannam
date Thu, 28 Feb 2019 13:21:36 +0000
parents 7a779792577d
children
comparison
equal deleted inserted replaced
16:c2387f117808 17:129ea1e6d783
1 <?php 1 <?php
2 2
3 namespace Drupal\simpletest; 3 namespace Drupal\simpletest;
4 4
5 use Drupal\Core\Routing\PreloadableRouteProviderInterface; 5 use Drupal\KernelTests\RouteProvider as CoreRouteProvider;
6 use Symfony\Cmf\Component\Routing\PagedRouteProviderInterface;
7 use Symfony\Component\HttpFoundation\Request;
8 6
9 /** 7 /**
10 * Rebuilds the router when the provider is instantiated. 8 * Rebuilds the router when the provider is instantiated.
11 * 9 *
12 * @todo Move this outside of simpletest namespace to the Drupal\Tests, see 10 * @deprecated in 8.6.0 for removal before 9.0.0. Use
13 * https://www.drupal.org/node/2672762 11 * Drupal\KernelTests\RouteProvider instead.
12 *
13 * @see https://www.drupal.org/node/2943146
14 */ 14 */
15 class RouteProvider implements PreloadableRouteProviderInterface, PagedRouteProviderInterface { 15 class RouteProvider extends CoreRouteProvider {
16
17 use \Drupal\Core\DependencyInjection\DependencySerializationTrait;
18
19 /**
20 * Loads the real route provider from the container and rebuilds the router.
21 *
22 * @return \Drupal\Core\Routing\PreloadableRouteProviderInterface|\Symfony\Cmf\Component\Routing\PagedRouteProviderInterface|\Symfony\Component\EventDispatcher\EventSubscriberInterface
23 * The route provider.
24 */
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();
30 }
31
32 return $this->service;
33 }
34
35 /**
36 * {@inheritdoc}
37 */
38 public function getRouteCollectionForRequest(Request $request) {
39 return $this->lazyLoadItself()->getRouteCollectionForRequest($request);
40 }
41
42 /**
43 * {@inheritdoc}
44 */
45 public function getRouteByName($name) {
46 return $this->lazyLoadItself()->getRouteByName($name);
47 }
48
49 /**
50 * {@inheritdoc}
51 */
52 public function preLoadRoutes($names) {
53 return $this->lazyLoadItself()->preLoadRoutes($names);
54 }
55
56 /**
57 * {@inheritdoc}
58 */
59 public function getRoutesByNames($names) {
60 return $this->lazyLoadItself()->getRoutesByNames($names);
61 }
62
63 /**
64 * {@inheritdoc}
65 */
66 public function getCandidateOutlines(array $parts) {
67 return $this->lazyLoadItself()->getCandidateOutlines($parts);
68 }
69
70 /**
71 * {@inheritdoc}
72 */
73 public function getRoutesByPattern($pattern) {
74 return $this->lazyLoadItself()->getRoutesByPattern($pattern);
75 }
76
77 /**
78 * {@inheritdoc}
79 */
80 public function routeProviderRouteCompare(array $a, array $b) {
81 return $this->lazyLoadItself()->routeProviderRouteCompare($a, $b);
82 }
83
84 /**
85 * {@inheritdoc}
86 */
87 public function getAllRoutes() {
88 return $this->lazyLoadItself()->getAllRoutes();
89 }
90
91 /**
92 * {@inheritdoc}
93 */
94 public function reset() {
95 return $this->lazyLoadItself()->reset();
96 }
97
98 /**
99 * {@inheritdoc}
100 */
101 public function getRoutesPaged($offset, $length = NULL) {
102 return $this->lazyLoadItself()->getRoutesPaged($offset, $length);
103 }
104
105 /**
106 * {@inheritdoc}
107 */
108 public function getRoutesCount() {
109 return $this->lazyLoadItself()->getRoutesCount();
110 }
111
112 } 16 }