Mercurial > hg > isophonics-drupal-site
comparison core/modules/simpletest/src/RouteProvider.php @ 0:4c8ae668cc8c
Initial import (non-working)
author | Chris Cannam |
---|---|
date | Wed, 29 Nov 2017 16:09:58 +0000 |
parents | |
children | 7a779792577d |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4c8ae668cc8c |
---|---|
1 <?php | |
2 | |
3 namespace Drupal\simpletest; | |
4 | |
5 use Drupal\Core\Routing\PreloadableRouteProviderInterface; | |
6 use Symfony\Cmf\Component\Routing\PagedRouteProviderInterface; | |
7 use Symfony\Component\HttpFoundation\Request; | |
8 | |
9 /** | |
10 * Rebuilds the router when the provider is instantiated. | |
11 * | |
12 * @todo Move this outside of simpletest namespace to the Drupal\Tests, see | |
13 * https://www.drupal.org/node/2672762 | |
14 */ | |
15 class RouteProvider implements PreloadableRouteProviderInterface, PagedRouteProviderInterface { | |
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 } |