1 | <?php |
||
17 | trait Router { |
||
18 | /** |
||
19 | * Path that will be used by controller to render page |
||
20 | * |
||
21 | * @var string[] |
||
22 | */ |
||
23 | protected $controller_path; |
||
24 | /** |
||
25 | * Execute router |
||
26 | * |
||
27 | * Depending on module, files-based or controller-based router might be used |
||
28 | * |
||
29 | * @throws ExitException |
||
30 | */ |
||
31 | protected function execute_router () { |
||
40 | /** |
||
41 | * Normalize `cs\Request::$route_path` and fill `cs\App::$controller_path` |
||
42 | * |
||
43 | * @param Request $Request |
||
44 | * |
||
45 | * @throws ExitException |
||
46 | */ |
||
47 | protected function check_and_normalize_route ($Request) { |
||
75 | /** |
||
76 | * @param string $path |
||
77 | * @param array $structure |
||
78 | * @param bool $api_path |
||
79 | * |
||
80 | * @throws ExitException |
||
81 | */ |
||
82 | protected function check_and_normalize_route_internal (&$path, $structure, $api_path) { |
||
102 | /** |
||
103 | * Include files necessary for module page rendering |
||
104 | * |
||
105 | * @param Request $Request |
||
106 | * |
||
107 | * @throws ExitException |
||
108 | */ |
||
109 | protected function files_router ($Request) { |
||
121 | /** |
||
122 | * Include files that corresponds for specific paths in URL |
||
123 | * |
||
124 | * @param Request $Request |
||
125 | * @param string $dir |
||
126 | * @param string $basename |
||
127 | * @param bool $required |
||
128 | * |
||
129 | * @throws ExitException |
||
130 | */ |
||
131 | protected function files_router_handler ($Request, $dir, $basename, $required = true) { |
||
134 | /** |
||
135 | * @param Request $Request |
||
136 | * @param string $dir |
||
137 | * @param string $basename |
||
138 | * @param bool $required |
||
139 | * |
||
140 | * @throws ExitException |
||
141 | */ |
||
142 | protected function files_router_handler_internal ($Request, $dir, $basename, $required) { |
||
156 | /** |
||
157 | * 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 |
||
158 | * methods also doesn't exist |
||
159 | * |
||
160 | * @param string[] $available_methods |
||
161 | * @param string $request_method |
||
162 | * |
||
163 | * @throws ExitException |
||
164 | */ |
||
165 | protected function handler_not_found ($available_methods, $request_method) { |
||
175 | /** |
||
176 | * Call methods necessary for module page rendering |
||
177 | * |
||
178 | * @param Request $Request |
||
179 | * |
||
180 | * @throws ExitException |
||
181 | */ |
||
182 | protected function controller_router ($Request) { |
||
201 | /** |
||
202 | * Call methods that corresponds for specific paths in URL |
||
203 | * |
||
204 | * @param Request $Request |
||
205 | * @param string $controller_class |
||
206 | * @param string $method_name |
||
207 | * @param bool $required |
||
208 | * |
||
209 | * @throws ExitException |
||
210 | */ |
||
211 | protected function controller_router_handler ($Request, $controller_class, $method_name, $required = true) { |
||
215 | /** |
||
216 | * @param Request $Request |
||
217 | * @param string $controller_class |
||
218 | * @param string $method_name |
||
219 | * @param bool $required |
||
220 | * |
||
221 | * @throws ExitException |
||
222 | */ |
||
223 | protected function controller_router_handler_internal ($Request, $controller_class, $method_name, $required) { |
||
247 | } |
||
248 |