1 | <?php |
||
9 | class Dispatcher |
||
10 | { |
||
11 | |||
12 | /** |
||
13 | * Routes array to be registered. |
||
14 | * Some routes may have aliases to be used in templating system |
||
15 | * Route item can be defined using array key as an alias key. |
||
16 | * Each route item is an array has items respectively: Request Method, Request Uri, Controller/Action, Return Type. |
||
17 | * |
||
18 | * @var array |
||
19 | */ |
||
20 | private $routes; |
||
21 | |||
22 | |||
23 | /** |
||
24 | * Default return type if not noted in the $routes |
||
25 | * |
||
26 | * @var int |
||
27 | */ |
||
28 | private $defaultReturnType; |
||
29 | |||
30 | /** |
||
31 | * @var null|string |
||
32 | */ |
||
33 | private $cachedFile; |
||
34 | |||
35 | /** |
||
36 | * @var array |
||
37 | */ |
||
38 | private $routerClosures = []; |
||
39 | |||
40 | private static $dispatchResults = [ |
||
41 | FastRoute\Dispatcher::METHOD_NOT_ALLOWED => 405, |
||
42 | FastRoute\Dispatcher::FOUND => 200 , |
||
43 | FastRoute\Dispatcher::NOT_FOUND => 404 |
||
44 | ]; |
||
45 | |||
46 | public function __construct(array $routes, int $defaultReturnType, ?string $cachedFile) |
||
52 | |||
53 | /* |
||
54 | * Dispatch against the provided HTTP method verb and URI. |
||
55 | */ |
||
56 | public function dispatcher() : FastRoute\Dispatcher |
||
73 | |||
74 | private function createCachedRoute($routeCollector) : void |
||
84 | |||
85 | |||
86 | private function cachedDispatcher() : FastRoute\Dispatcher\GroupCountBased |
||
94 | |||
95 | /* |
||
96 | * Define Closures for all routes that returns controller info to be used. |
||
97 | */ |
||
98 | private function addRoutes(FastRoute\RouteCollector $route) : void |
||
108 | |||
109 | private function setRouteClosures() : void |
||
130 | |||
131 | public function runDispatcher(array $routeInfo) : Route |
||
136 | |||
137 | private function getRouteData(array $routeInfo) : Route |
||
153 | } |
||
154 |