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 $cacheFile; |
||
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 $cacheFile) |
||
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 | private function cachedDispatcher() : FastRoute\Dispatcher\GroupCountBased |
||
93 | |||
94 | /* |
||
95 | * Define Closures for all routes that returns controller info to be used. |
||
96 | */ |
||
97 | private function addRoutes(FastRoute\RouteCollector $route) : void |
||
107 | |||
108 | private function setRouteClosures() : void |
||
129 | |||
130 | public function runDispatcher(array $routeInfo) : Route |
||
135 | |||
136 | private function getRouteData(array $routeInfo) : Route |
||
152 | } |
||
153 |