comparison core/tests/Drupal/KernelTests/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
children
comparison
equal deleted inserted replaced
16:c2387f117808 17:129ea1e6d783
1 <?php
2
3 namespace Drupal\KernelTests;
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 class RouteProvider implements PreloadableRouteProviderInterface, PagedRouteProviderInterface {
13
14 use \Drupal\Core\DependencyInjection\DependencySerializationTrait;
15
16 /**
17 * Loads the real route provider from the container and rebuilds the router.
18 *
19 * @return \Drupal\Core\Routing\PreloadableRouteProviderInterface|\Symfony\Cmf\Component\Routing\PagedRouteProviderInterface|\Symfony\Component\EventDispatcher\EventSubscriberInterface
20 * The route provider.
21 */
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();
27 }
28
29 return $this->service;
30 }
31
32 /**
33 * {@inheritdoc}
34 */
35 public function getRouteCollectionForRequest(Request $request) {
36 return $this->lazyLoadItself()->getRouteCollectionForRequest($request);
37 }
38
39 /**
40 * {@inheritdoc}
41 */
42 public function getRouteByName($name) {
43 return $this->lazyLoadItself()->getRouteByName($name);
44 }
45
46 /**
47 * {@inheritdoc}
48 */
49 public function preLoadRoutes($names) {
50 return $this->lazyLoadItself()->preLoadRoutes($names);
51 }
52
53 /**
54 * {@inheritdoc}
55 */
56 public function getRoutesByNames($names) {
57 return $this->lazyLoadItself()->getRoutesByNames($names);
58 }
59
60 /**
61 * {@inheritdoc}
62 */
63 public function getCandidateOutlines(array $parts) {
64 return $this->lazyLoadItself()->getCandidateOutlines($parts);
65 }
66
67 /**
68 * {@inheritdoc}
69 */
70 public function getRoutesByPattern($pattern) {
71 return $this->lazyLoadItself()->getRoutesByPattern($pattern);
72 }
73
74 /**
75 * {@inheritdoc}
76 */
77 public function routeProviderRouteCompare(array $a, array $b) {
78 return $this->lazyLoadItself()->routeProviderRouteCompare($a, $b);
79 }
80
81 /**
82 * {@inheritdoc}
83 */
84 public function getAllRoutes() {
85 return $this->lazyLoadItself()->getAllRoutes();
86 }
87
88 /**
89 * {@inheritdoc}
90 */
91 public function reset() {
92 return $this->lazyLoadItself()->reset();
93 }
94
95 /**
96 * {@inheritdoc}
97 */
98 public function getRoutesPaged($offset, $length = NULL) {
99 return $this->lazyLoadItself()->getRoutesPaged($offset, $length);
100 }
101
102 /**
103 * {@inheritdoc}
104 */
105 public function getRoutesCount() {
106 return $this->lazyLoadItself()->getRoutesCount();
107 }
108
109 }