1 | <?php |
||
10 | final class Framework |
||
11 | { |
||
12 | private $projectNamespace = '\Project'; |
||
13 | private $controllerPackage = '\Controller'; |
||
14 | private $controllerActionSuffix = 'Action'; |
||
15 | private $withParameterMatching = false; |
||
16 | |||
17 | /** |
||
18 | * Dispatch the request |
||
19 | * @throws \Exception |
||
20 | * @return mixed |
||
21 | */ |
||
22 | 12 | public function dispatch() |
|
42 | |||
43 | /** |
||
44 | * Returns parameters from request matching specified controller and action |
||
45 | * @param object $controller |
||
46 | * @param string $action |
||
47 | * @return array |
||
48 | */ |
||
49 | 8 | private function getParametersForMatching($controller, string $action): array |
|
60 | |||
61 | /** |
||
62 | * Return Controller instance from a controller name |
||
63 | * @param string $controllerName |
||
64 | * @return object |
||
65 | * @throws \Exception |
||
66 | */ |
||
67 | 12 | private function getControllerFromName(string $controllerName) |
|
75 | |||
76 | /** |
||
77 | * Return HTTP Method for request |
||
78 | * @return string |
||
79 | */ |
||
80 | 9 | private function getVerbFromRequest(): string |
|
84 | |||
85 | /** |
||
86 | * Returns Request uri without query string |
||
87 | * @return string |
||
88 | */ |
||
89 | 12 | private function getQuery(): string |
|
95 | |||
96 | /** |
||
97 | * Determine controller and action from Request Uri |
||
98 | * @return array |
||
99 | */ |
||
100 | 12 | private function getControllerAndAction(): array |
|
107 | |||
108 | /** |
||
109 | * Redefine personal namespace |
||
110 | * @param string $namespace |
||
111 | * @return Framework |
||
112 | */ |
||
113 | 6 | public function setNamespace(string $namespace = '\Project'): Framework |
|
118 | |||
119 | /** |
||
120 | * Redefine controller subpackage |
||
121 | * @param string $controllerPackage |
||
122 | * @return Framework |
||
123 | */ |
||
124 | 7 | public function setControllerPackage(string $controllerPackage = '\Controller'): Framework |
|
131 | |||
132 | /** |
||
133 | * Redefine controller action suffix |
||
134 | * @param string $suffix |
||
135 | * @return Framework |
||
136 | */ |
||
137 | 5 | public function setControllerActionSuffix(string $suffix = 'Action'): Framework |
|
142 | |||
143 | /** |
||
144 | * Tells if we should use parameter matching for controllers |
||
145 | * @param bool $active |
||
146 | * @return Framework |
||
147 | */ |
||
148 | 2 | public function setParameterMatching($active = true): Framework |
|
153 | } |
||
154 |