1 | <?php |
||
26 | class Controller |
||
27 | { |
||
28 | |||
29 | /** |
||
30 | * Holds the views per controller request |
||
31 | * |
||
32 | * @var array |
||
33 | */ |
||
34 | private $_viewArray = []; |
||
35 | |||
36 | /** |
||
37 | * Holds the request |
||
38 | * |
||
39 | * @var Request |
||
40 | */ |
||
41 | protected $request; |
||
42 | |||
43 | /** |
||
44 | * AbstractController constructor. |
||
45 | * |
||
46 | * @param Request $request The request object |
||
47 | */ |
||
48 | public function __construct(Request $request) |
||
52 | |||
53 | /** |
||
54 | * Returns the service locator |
||
55 | * |
||
56 | * @return ServiceLocator |
||
57 | */ |
||
58 | public function getServiceLocator() :ServiceLocator |
||
62 | |||
63 | /** |
||
64 | * Returns the session manager |
||
65 | * |
||
66 | * @return SessionManager|ServiceInterface |
||
67 | */ |
||
68 | public function getSessionManager() :SessionManager |
||
72 | |||
73 | /** |
||
74 | * Returns the view controller |
||
75 | * |
||
76 | * @return ViewController |
||
77 | */ |
||
78 | public function getView() :ViewController |
||
93 | |||
94 | /** |
||
95 | * Returns the orm/entity manager |
||
96 | * |
||
97 | * @return DbService|ServiceInterface |
||
98 | */ |
||
99 | public function getDb() :DbService |
||
103 | |||
104 | /** |
||
105 | * Render view with given template |
||
106 | * |
||
107 | * @param string $template The template to be rendered |
||
108 | * @param array $variables The variables for the template |
||
109 | * |
||
110 | * @return Response |
||
111 | */ |
||
112 | public function render(string $template = '', $variables = []) :Response |
||
135 | |||
136 | /** |
||
137 | * Check if user is permitted based on his role(s) |
||
138 | * |
||
139 | * @param array $roles The corresponding user roles |
||
140 | * |
||
141 | * @return bool|null |
||
142 | */ |
||
143 | public function isPermitted($roles = []) |
||
150 | |||
151 | /** |
||
152 | * Redirect to specific uri |
||
153 | * |
||
154 | * @param string $uri The target uri |
||
155 | * |
||
156 | * @return bool |
||
157 | * |
||
158 | * @throws InvalidArgumentException |
||
159 | */ |
||
160 | public function redirect(string $uri) :bool |
||
166 | |||
167 | /** |
||
168 | * Set a generic text token which is valid for exactly one call |
||
169 | * |
||
170 | * @param string $key Key for the flash message |
||
171 | * @param string $message Content for the flash message |
||
172 | * |
||
173 | * @return void |
||
174 | */ |
||
175 | public function setFlashMessage(string $key, string $message) |
||
180 | |||
181 | /** |
||
182 | * Retrieve a flash message |
||
183 | * |
||
184 | * @param string $key The flash message key |
||
185 | * |
||
186 | * @return string|null |
||
187 | */ |
||
188 | public function getFlashMessage(string $key) |
||
193 | |||
194 | /** |
||
195 | * Get the url for a specific route name |
||
196 | * |
||
197 | * @param string $name Name of the route |
||
198 | * @param array $parameters Apply parameters where necessary |
||
199 | * @param bool $absolute Return an absolute url with host as prefix |
||
200 | * |
||
201 | * @return string |
||
202 | */ |
||
203 | public function route(string $name, array $parameters = [], $absolute = false) |
||
207 | |||
208 | /** |
||
209 | * Return the current request object |
||
210 | * |
||
211 | * @return Request |
||
212 | */ |
||
213 | public function getRequest() :Request |
||
217 | |||
218 | /** |
||
219 | * Add default assets for every action |
||
220 | */ |
||
221 | protected function addAssets() { |
||
224 | |||
225 | } |
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: