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 | 10 | */ |
|
22 | public function dispatch() |
||
36 | |||
37 | 5 | /** |
|
38 | * @param \object $controller |
||
39 | * @param string $action |
||
40 | * @return array |
||
41 | */ |
||
42 | private function getParameterMatching(\object $controller, string $action) : array |
||
53 | 10 | ||
54 | /** |
||
55 | 10 | * Return Controller instance from a controller name |
|
56 | 10 | * @param string $controllerName |
|
57 | 10 | * @return object |
|
58 | * @throws \Exception |
||
59 | */ |
||
60 | private function getControllerFromName(string $controllerName) |
||
68 | 10 | ||
69 | 10 | /** |
|
70 | * Return HTTP Method for request |
||
71 | * @return string |
||
72 | */ |
||
73 | private function getVerbFromRequest() : string |
||
77 | 4 | ||
78 | /** |
||
79 | 4 | * Returns Request uri without query string |
|
80 | 4 | * @return string |
|
81 | */ |
||
82 | private function getQuery() : string |
||
88 | 5 | ||
89 | /** |
||
90 | 5 | * Determine controller and action from Request Uri |
|
91 | 2 | * @return array |
|
92 | 3 | */ |
|
93 | 5 | private function getControllerAndAction() : array |
|
100 | |||
101 | 3 | /** |
|
102 | * Redefine personal namespace |
||
103 | 3 | * @param string $namespace |
|
104 | 3 | * @return Framework |
|
105 | */ |
||
106 | public function setNamespace(string $namespace = '\Project') : Framework |
||
111 | |||
112 | /** |
||
113 | * Redefine controller subpackage |
||
114 | * @param string $controllerPackage |
||
115 | * @return Framework |
||
116 | */ |
||
117 | public function setControllerPackage(string $controllerPackage = '\Controller') : Framework |
||
124 | |||
125 | /** |
||
126 | * Redefine controller action suffix |
||
127 | * @param string $suffix |
||
128 | * @return Framework |
||
129 | */ |
||
130 | public function setControllerActionSuffix(string $suffix = 'Action') : Framework |
||
135 | |||
136 | /** |
||
137 | * Tells if we should use parameter matching for controllers |
||
138 | * @param bool $active |
||
139 | * @return Framework |
||
140 | */ |
||
141 | public function setParameterMatching($active = true) : Framework |
||
146 | } |
||
147 |