1 | <?php |
||
27 | class SplashDefaultRouter implements MiddlewareInterface |
||
28 | { |
||
29 | /** |
||
30 | * The container that will be used to fetch controllers. |
||
31 | * |
||
32 | * @var ContainerInterface |
||
33 | */ |
||
34 | private $container; |
||
35 | |||
36 | /** |
||
37 | * List of objects that provide routes. |
||
38 | * |
||
39 | * @var UrlProviderInterface[] |
||
40 | */ |
||
41 | private $routeProviders = []; |
||
42 | |||
43 | /** |
||
44 | * The logger used by Splash. |
||
45 | * |
||
46 | * @var LoggerInterface |
||
47 | */ |
||
48 | private $log; |
||
49 | |||
50 | /** |
||
51 | * Splash uses the cache service to store the URL mapping (the mapping between a URL and its controller/action). |
||
52 | * |
||
53 | * @var CacheItemPoolInterface |
||
54 | */ |
||
55 | private $cachePool; |
||
56 | |||
57 | /** |
||
58 | * The default mode for Splash. Can be one of 'weak' (controllers are allowed to output HTML), or 'strict' (controllers |
||
59 | * are requested to return a ResponseInterface object). |
||
60 | * |
||
61 | * @var string |
||
62 | */ |
||
63 | private $mode; |
||
64 | |||
65 | /** |
||
66 | * In debug mode, Splash will display more accurate messages if output starts (in strict mode). |
||
67 | * |
||
68 | * @var bool |
||
69 | */ |
||
70 | private $debug; |
||
71 | |||
72 | /** |
||
73 | * @var ParameterFetcher[] |
||
74 | */ |
||
75 | private $parameterFetcherRegistry; |
||
76 | |||
77 | /** |
||
78 | * The base URL of the application (from which the router will start routing). |
||
79 | * |
||
80 | * @var string |
||
81 | */ |
||
82 | private $rootUrl; |
||
83 | |||
84 | /** |
||
85 | * (optional) Handles HTTP 400 status code. |
||
86 | * |
||
87 | * @var Http400HandlerInterface |
||
88 | */ |
||
89 | private $http400Handler; |
||
90 | |||
91 | /** |
||
92 | * (optional) Handles HTTP 404 status code (if no $out provided). |
||
93 | * |
||
94 | * @var Http404HandlerInterface |
||
95 | */ |
||
96 | private $http404Handler; |
||
97 | |||
98 | /** |
||
99 | * (optional) Handles HTTP 500 status code. |
||
100 | * |
||
101 | * @var Http500HandlerInterface |
||
102 | */ |
||
103 | private $http500Handler; |
||
104 | |||
105 | /** |
||
106 | * @Important |
||
107 | * |
||
108 | * @param ContainerInterface $container The container that will be used to fetch controllers. |
||
109 | * @param UrlProviderInterface[] $routeProviders |
||
110 | * @param ParameterFetcherRegistry $parameterFetcherRegistry |
||
111 | * @param CacheItemPoolInterface $cachePool Splash uses the cache service to store the URL mapping (the mapping between a URL and its controller/action) |
||
112 | * @param LoggerInterface $log The logger used by Splash |
||
113 | * @param string $mode The default mode for Splash. Can be one of 'weak' (controllers are allowed to output HTML), or 'strict' (controllers are requested to return a ResponseInterface object). |
||
114 | * @param bool $debug In debug mode, Splash will display more accurate messages if output starts (in strict mode) |
||
115 | * @param string $rootUrl |
||
116 | */ |
||
117 | public function __construct(ContainerInterface $container, array $routeProviders, ParameterFetcherRegistry $parameterFetcherRegistry, CacheItemPoolInterface $cachePool = null, LoggerInterface $log = null, $mode = SplashUtils::MODE_STRICT, $debug = true, $rootUrl = '/') |
||
128 | |||
129 | /** |
||
130 | * @param Http400HandlerInterface $http400Handler |
||
131 | */ |
||
132 | public function setHttp400Handler($http400Handler) |
||
138 | |||
139 | /** |
||
140 | * @param Http404HandlerInterface $http404Handler |
||
141 | */ |
||
142 | public function setHttp404Handler($http404Handler) |
||
148 | |||
149 | /** |
||
150 | * @param Http500HandlerInterface $http500Handler |
||
151 | */ |
||
152 | public function setHttp500Handler($http500Handler) |
||
158 | |||
159 | /** |
||
160 | * Process an incoming request and/or response. |
||
161 | * |
||
162 | * Accepts a server-side request and a response instance, and does |
||
163 | * something with them. |
||
164 | * |
||
165 | * If the response is not complete and/or further processing would not |
||
166 | * interfere with the work done in the middleware, or if the middleware |
||
167 | * wants to delegate to another process, it can use the `$out` callable |
||
168 | * if present. |
||
169 | * |
||
170 | * If the middleware does not return a value, execution of the current |
||
171 | * request is considered complete, and the response instance provided will |
||
172 | * be considered the response to return. |
||
173 | * |
||
174 | * Alternately, the middleware may return a response instance. |
||
175 | * |
||
176 | * Often, middleware will `return $out();`, with the assumption that a |
||
177 | * later middleware will return a response. |
||
178 | * |
||
179 | * @param ServerRequestInterface $request |
||
180 | * @param ResponseInterface $response |
||
181 | * @param null|callable $out |
||
182 | * |
||
183 | * @return null|ResponseInterface |
||
184 | */ |
||
185 | public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $out = null) |
||
317 | |||
318 | /** |
||
319 | * Purges the cache if one of the url providers tells us to. |
||
320 | */ |
||
321 | private function purgeExpiredRoutes() |
||
342 | |||
343 | |||
344 | /** |
||
345 | * Returns the list of all SplashActions. |
||
346 | * This call is LONG and should be cached. |
||
347 | * |
||
348 | * @return array<SplashAction> |
||
349 | */ |
||
350 | public function getSplashActionsList() |
||
362 | |||
363 | /** |
||
364 | * Generates the URLNodes from the list of URLS. |
||
365 | * URLNodes are a very efficient way to know whether we can access our page or not. |
||
366 | * |
||
367 | * @param array<SplashAction> $urlsList |
||
368 | * |
||
369 | * @return SplashUrlNode |
||
370 | */ |
||
371 | private function generateUrlNode($urlsList) |
||
380 | |||
381 | /** |
||
382 | * Purges the urls cache. |
||
383 | */ |
||
384 | public function purgeUrlsCache() |
||
388 | } |
||
389 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..