1 | <?php |
||
18 | trait Router { |
||
19 | use |
||
20 | CLI, |
||
21 | Controller, |
||
22 | Files; |
||
23 | /** |
||
24 | * Path that will be used by controller to render page |
||
25 | * |
||
26 | * @var string[] |
||
27 | */ |
||
28 | protected $controller_path; |
||
29 | /** |
||
30 | * @var string |
||
31 | */ |
||
32 | protected $working_directory; |
||
33 | 14 | protected function init_router () { |
|
37 | /** |
||
38 | * Execute router |
||
39 | * |
||
40 | * Depending on module, files-based or controller-based router might be used |
||
41 | * |
||
42 | * @param \cs\Request $Request |
||
43 | * |
||
44 | * @throws ExitException |
||
45 | */ |
||
46 | 8 | protected function execute_router ($Request) { |
|
66 | /** |
||
67 | * @param \cs\Request $Request |
||
68 | * |
||
69 | * @return string |
||
70 | * |
||
71 | * @throws ExitException |
||
72 | */ |
||
73 | 8 | protected function get_working_directory ($Request) { |
|
88 | /** |
||
89 | * Normalize `cs\Request::$route_path` and fill `cs\App::$controller_path` |
||
90 | * |
||
91 | * @param \cs\Request $Request |
||
92 | * |
||
93 | * @throws ExitException |
||
94 | */ |
||
95 | 8 | protected function check_and_normalize_route ($Request) { |
|
123 | /** |
||
124 | * @param \cs\Request $Request |
||
125 | * @param string $path |
||
126 | * @param array $structure |
||
127 | * @param bool $cli_or_api_path |
||
128 | * |
||
129 | * @throws ExitException |
||
130 | */ |
||
131 | 8 | protected function check_and_normalize_route_internal ($Request, &$path, $structure, $cli_or_api_path) { |
|
150 | /** |
||
151 | * If HTTP method handler not found we generate either `501 Not Implemented` if other methods are supported or `404 Not Found` if handlers for others |
||
152 | * methods also doesn't exist |
||
153 | * |
||
154 | * @param string[] $available_methods |
||
155 | * @param string $request_method |
||
156 | * @param \cs\Request $Request |
||
157 | * |
||
158 | * @throws ExitException |
||
159 | */ |
||
160 | protected function handler_not_found ($available_methods, $request_method, $Request) { |
||
177 | } |
||
178 |