1 | <?php |
||
13 | class Route |
||
14 | { |
||
15 | use RouteReflection; |
||
16 | |||
17 | /** @var string */ |
||
18 | protected $url; |
||
19 | |||
20 | /** @var */ |
||
21 | protected $callable; |
||
22 | |||
23 | /** @var */ |
||
24 | protected $name; |
||
25 | |||
26 | /** @var array */ |
||
27 | private static $parameters = []; |
||
28 | |||
29 | /** @var array */ |
||
30 | private static $attributes = []; |
||
31 | |||
32 | /** @var Request */ |
||
33 | protected $request; |
||
34 | |||
35 | /** @var Response */ |
||
36 | protected $response; |
||
37 | |||
38 | /** @var */ |
||
39 | protected $running; |
||
40 | |||
41 | /** |
||
42 | * Route constructor. |
||
43 | * @param $url |
||
44 | * @param $callable |
||
45 | * @param null $name |
||
46 | */ |
||
47 | public function __construct($url, $callable, $name = null) |
||
55 | |||
56 | /** |
||
57 | * Check the path, if there are parameters to create attributes for the scope of the request |
||
58 | * |
||
59 | * @param $url |
||
60 | * @return bool |
||
61 | */ |
||
62 | public function extractParameters($url) |
||
73 | |||
74 | /** |
||
75 | * ... |
||
76 | * |
||
77 | * @param $match |
||
78 | * @return string |
||
79 | */ |
||
80 | private function attributesMatch($match) { |
||
86 | |||
87 | /** |
||
88 | * Get url. |
||
89 | * |
||
90 | * @return string |
||
91 | */ |
||
92 | public function getUrl(): string |
||
96 | |||
97 | /** |
||
98 | * Get name route |
||
99 | * |
||
100 | * @return null|string |
||
101 | */ |
||
102 | public function getName() |
||
106 | |||
107 | /** |
||
108 | * Get callback. |
||
109 | * |
||
110 | * @return mixed |
||
111 | */ |
||
112 | public function getCallable() |
||
116 | |||
117 | /** |
||
118 | * Get params. |
||
119 | * |
||
120 | * @return array |
||
121 | */ |
||
122 | public static function getParameters(): array |
||
126 | |||
127 | /** |
||
128 | * Get properties on route |
||
129 | * |
||
130 | * @return array |
||
131 | */ |
||
132 | public function getRoute() |
||
141 | |||
142 | /** |
||
143 | * Get request |
||
144 | * |
||
145 | * @return Request |
||
146 | */ |
||
147 | public function getRequest(): Request |
||
151 | |||
152 | /** |
||
153 | * Get reponse |
||
154 | * |
||
155 | * @return Response |
||
156 | */ |
||
157 | public function getResponse(): Response |
||
161 | |||
162 | /** |
||
163 | * Executing route |
||
164 | * |
||
165 | * @param array $parameters |
||
166 | * @return mixed |
||
167 | */ |
||
168 | public function requestUrlCall($parameters = []) |
||
177 | |||
178 | /** |
||
179 | * Exporta para o controlador uma coleção de dados; |
||
180 | * |
||
181 | * @param string $attribute |
||
182 | * @param string $regex |
||
183 | * @return $this |
||
184 | */ |
||
185 | public function with(string $attribute, string $regex) |
||
190 | |||
191 | /** |
||
192 | * Check the type of request and define which treatment it should receive |
||
193 | * |
||
194 | * @return mixed |
||
195 | */ |
||
196 | public function run() |
||
203 | /** |
||
204 | * ... |
||
205 | * |
||
206 | * @return mixed |
||
207 | */ |
||
208 | protected function handleRequestCallable() |
||
214 | |||
215 | /** |
||
216 | * ... |
||
217 | * |
||
218 | * @return mixed |
||
219 | */ |
||
220 | protected function handleRequestController() |
||
227 | } |