1 | <?php |
||
18 | class Router |
||
19 | { |
||
20 | /** |
||
21 | * @var \BFW\Module $module The bfw module instance for this module |
||
22 | */ |
||
23 | protected $module; |
||
24 | |||
25 | /** |
||
26 | * @var \BFW\Config $config The bfw config instance for this module |
||
27 | */ |
||
28 | protected $config; |
||
29 | |||
30 | /** |
||
31 | * @var \BFW\ControllerRouterLink $routerLinker Linker between |
||
32 | * controller and router instance |
||
33 | */ |
||
34 | protected $routerLinker; |
||
35 | |||
36 | /** |
||
37 | * @var \FastRoute\Dispatcher $dispatcher FastRoute dispatcher |
||
38 | */ |
||
39 | protected $dispatcher; |
||
40 | |||
41 | /** |
||
42 | * Constructor |
||
43 | * Get config and linker instance |
||
44 | * Call fastRoute dispatcher |
||
45 | * |
||
46 | * @param \BFW\Module $module |
||
47 | */ |
||
48 | public function __construct(\BFW\Module $module) |
||
57 | |||
58 | /** |
||
59 | * Call by dispatcher; Add route in config to fastRoute router |
||
60 | * |
||
61 | * @param FastRoute\RouteCollector $router FastRoute router |
||
62 | * |
||
63 | * @return void |
||
64 | */ |
||
65 | public function addRoutesToCollector(FastRoute\RouteCollector $router) |
||
85 | |||
86 | /** |
||
87 | * Obtain informations about the current route from fastRoute dispatcher |
||
88 | * |
||
89 | * @return void |
||
90 | */ |
||
91 | public function obtainCurrentRoute() |
||
124 | |||
125 | /** |
||
126 | * Get http status for response from dispatcher |
||
127 | * |
||
128 | * @param int $routeStatus : Route status send by dispatcher for request |
||
129 | * |
||
130 | * @return int |
||
131 | */ |
||
132 | protected function checkStatus($routeStatus) |
||
144 | |||
145 | /** |
||
146 | * Obtains route informations from config file and send this informations |
||
147 | * to the controller/router linker |
||
148 | * |
||
149 | * @param array $routeInfos : Route information from config file |
||
150 | * |
||
151 | * @return void |
||
152 | * |
||
153 | * @throws \Exception If target not define in config file |
||
154 | */ |
||
155 | protected function sendInfosForRouteToLinker(array $routeInfos) |
||
163 | |||
164 | /** |
||
165 | * Add datas into a superglobal var |
||
166 | * |
||
167 | * @param string $globalVarName : Name of the superglobal var |
||
168 | * @param array $datasToAdd : Datas to add to $_GET var |
||
169 | * |
||
170 | * @return void |
||
171 | */ |
||
172 | protected function addToSuperglobalVar($globalVarName, array $datasToAdd) |
||
177 | |||
178 | /** |
||
179 | * If property 'get' has been declared into current route config, add |
||
180 | * them into superglobal $_GET . |
||
181 | * |
||
182 | * @param array $routeInfos route informations declared in config |
||
183 | * |
||
184 | * @return void |
||
185 | */ |
||
186 | protected function addDatasToGetAndPostVar(array $routeInfos) |
||
192 | |||
193 | /** |
||
194 | * Send to all observer of Application a notify who contains the message |
||
195 | * "request_route_find" to say the route for the current request has been |
||
196 | * found by us. |
||
197 | * |
||
198 | * @return void |
||
199 | */ |
||
200 | protected function sendNotifyRouteFindToOthers() |
||
205 | } |
||
206 |