1 | <?php declare(strict_types=1); |
||
30 | class Controller { |
||
31 | |||
32 | use ContainerAware; |
||
33 | |||
34 | /** |
||
35 | * Cache manager |
||
36 | * @var \Aviat\Ion\Cache\CacheInterface |
||
37 | */ |
||
38 | protected $cache; |
||
39 | |||
40 | /** |
||
41 | * The global configuration object |
||
42 | * @var Aviat\Ion\ConfigInterface $config |
||
43 | */ |
||
44 | protected $config; |
||
45 | |||
46 | /** |
||
47 | * Request object |
||
48 | * @var object $request |
||
49 | */ |
||
50 | protected $request; |
||
51 | |||
52 | /** |
||
53 | * Response object |
||
54 | * @var object $response |
||
55 | */ |
||
56 | protected $response; |
||
57 | |||
58 | /** |
||
59 | * The api model for the current controller |
||
60 | * @var object |
||
61 | */ |
||
62 | protected $model; |
||
63 | |||
64 | /** |
||
65 | * Url generation class |
||
66 | * @var UrlGenerator |
||
67 | */ |
||
68 | protected $urlGenerator; |
||
69 | |||
70 | /** |
||
71 | * Session segment |
||
72 | * @var [type] |
||
73 | */ |
||
74 | protected $session; |
||
75 | |||
76 | /** |
||
77 | * Common data to be sent to views |
||
78 | * @var array |
||
79 | */ |
||
80 | protected $base_data = [ |
||
81 | 'url_type' => 'anime', |
||
82 | 'other_type' => 'manga', |
||
83 | 'menu_name' => '' |
||
84 | ]; |
||
85 | |||
86 | /** |
||
87 | * Constructor |
||
88 | * |
||
89 | * @param ContainerInterface $container |
||
|
|||
90 | */ |
||
91 | public function __construct(ContainerInterface $container) |
||
119 | |||
120 | /** |
||
121 | * Redirect to the default controller/url from an empty path |
||
122 | * |
||
123 | * @return void |
||
124 | */ |
||
125 | public function redirectToDefaultRoute() |
||
130 | |||
131 | /** |
||
132 | * Redirect to the previous page |
||
133 | * |
||
134 | * @return void |
||
135 | */ |
||
136 | public function redirect_to_previous() |
||
141 | |||
142 | /** |
||
143 | * Set the current url in the session as the target of a future redirect |
||
144 | * |
||
145 | * @param string|null $url |
||
146 | * @return void |
||
147 | */ |
||
148 | public function set_session_redirect($url = NULL) |
||
177 | |||
178 | /** |
||
179 | * Redirect to the url previously set in the session |
||
180 | * |
||
181 | * @return void |
||
182 | */ |
||
183 | public function session_redirect() |
||
196 | |||
197 | /** |
||
198 | * Get a class member |
||
199 | * |
||
200 | * @param string $key |
||
201 | * @return mixed |
||
202 | */ |
||
203 | public function __get(string $key) |
||
214 | |||
215 | /** |
||
216 | * Get the string output of a partial template |
||
217 | * |
||
218 | * @param HtmlView $view |
||
219 | * @param string $template |
||
220 | * @param array $data |
||
221 | * @throws InvalidArgumentException |
||
222 | * @return string |
||
223 | */ |
||
224 | protected function load_partial($view, $template, array $data = []) |
||
246 | |||
247 | /** |
||
248 | * Render a template with header and footer |
||
249 | * |
||
250 | * @param HtmlView $view |
||
251 | * @param string $template |
||
252 | * @param array $data |
||
253 | * @return void |
||
254 | */ |
||
255 | protected function render_full_page($view, $template, array $data) |
||
267 | |||
268 | /** |
||
269 | * Show the login form |
||
270 | * |
||
271 | * @codeCoverageIgnore |
||
272 | * @param string $status |
||
273 | * @return void |
||
274 | */ |
||
275 | public function login(string $status = '') |
||
294 | |||
295 | /** |
||
296 | * Attempt login authentication |
||
297 | * |
||
298 | * @return void |
||
299 | */ |
||
300 | public function loginAction() |
||
312 | |||
313 | /** |
||
314 | * Deauthorize the current user |
||
315 | * |
||
316 | * @return void |
||
317 | */ |
||
318 | public function logout() |
||
325 | |||
326 | /** |
||
327 | * 404 action |
||
328 | * |
||
329 | * @return void |
||
330 | */ |
||
331 | public function notFound() |
||
337 | |||
338 | /** |
||
339 | * Display a generic error page |
||
340 | * |
||
341 | * @param int $http_code |
||
342 | * @param string $title |
||
343 | * @param string $message |
||
344 | * @param string $long_message |
||
345 | * @return void |
||
346 | */ |
||
347 | public function errorPage($http_code, $title, $message, $long_message = "") |
||
355 | |||
356 | /** |
||
357 | * Set a session flash variable to display a message on |
||
358 | * next page load |
||
359 | * |
||
360 | * @param string $message |
||
361 | * @param string $type |
||
362 | * @return void |
||
363 | */ |
||
364 | public function set_flash_message($message, $type = "info") |
||
371 | |||
372 | /** |
||
373 | * Purges the API cache |
||
374 | * |
||
375 | * @return void |
||
376 | */ |
||
377 | public function clearCache() |
||
384 | |||
385 | /** |
||
386 | * Add a message box to the page |
||
387 | * |
||
388 | * @codeCoverageIgnore |
||
389 | * @param HtmlView $view |
||
390 | * @param string $type |
||
391 | * @param string $message |
||
392 | * @return string |
||
393 | */ |
||
394 | protected function showMessage($view, $type, $message) |
||
401 | |||
402 | /** |
||
403 | * Output a template to HTML, using the provided data |
||
404 | * |
||
405 | * @param string $template |
||
406 | * @param array $data |
||
407 | * @param HtmlView|null $view |
||
408 | * @param int $code |
||
409 | * @return void |
||
410 | */ |
||
411 | protected function outputHTML($template, array $data = [], $view = NULL, $code = 200) |
||
421 | |||
422 | /** |
||
423 | * Output a JSON Response |
||
424 | * |
||
425 | * @param mixed $data |
||
426 | * @param int $code - the http status code |
||
427 | * @return void |
||
428 | */ |
||
429 | protected function outputJSON($data = 'Empty response', int $code = 200) |
||
436 | |||
437 | /** |
||
438 | * Redirect to the selected page |
||
439 | * |
||
440 | * @param string $url |
||
441 | * @param int $code |
||
442 | * @return void |
||
443 | */ |
||
444 | protected function redirect($url, $code) |
||
449 | } |
||
450 | // End of BaseController.php |
This check looks for
@param
annotations where the type inferred by our type inference engine differs from the declared type.It makes a suggestion as to what type it considers more descriptive.
Most often this is a case of a parameter that can be null in addition to its declared types.