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 | protected function init_router () { |
||
32 | /** |
||
33 | * Execute router |
||
34 | * |
||
35 | * Depending on module, files-based or controller-based router might be used |
||
36 | * |
||
37 | * @throws ExitException |
||
38 | */ |
||
39 | protected function execute_router () { |
||
52 | /** |
||
53 | * Normalize `cs\Request::$route_path` and fill `cs\App::$controller_path` |
||
54 | * |
||
55 | * @param Request $Request |
||
56 | * |
||
57 | * @throws ExitException |
||
58 | */ |
||
59 | protected function check_and_normalize_route ($Request) { |
||
87 | /** |
||
88 | * @param string $path |
||
89 | * @param array $structure |
||
90 | * @param bool $cli_or_api_path |
||
91 | * |
||
92 | * @throws ExitException |
||
93 | */ |
||
94 | protected function check_and_normalize_route_internal (&$path, $structure, $cli_or_api_path) { |
||
114 | /** |
||
115 | * 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 |
||
116 | * methods also doesn't exist |
||
117 | * |
||
118 | * @param string[] $available_methods |
||
119 | * @param string $request_method |
||
120 | * @param Request $Request |
||
121 | * |
||
122 | * @throws ExitException |
||
123 | */ |
||
124 | protected function handler_not_found ($available_methods, $request_method, $Request) { |
||
141 | } |
||
142 |