1 | <?php |
||
26 | class Controller |
||
27 | { |
||
28 | |||
29 | /** |
||
30 | * Contains the views per controller request |
||
31 | * |
||
32 | * @var array |
||
33 | */ |
||
34 | private $_viewArray = []; |
||
35 | |||
36 | /** |
||
37 | * Contains the current 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 = '', array $variables = []) :Response |
||
134 | |||
135 | /** |
||
136 | * Check if user is permitted based on his role(s) |
||
137 | * |
||
138 | * @param array $roles The corresponding user roles |
||
139 | * |
||
140 | * @return bool |
||
141 | */ |
||
142 | public function isPermitted(array $roles = []): bool |
||
149 | |||
150 | /** |
||
151 | * Redirect to specific uri |
||
152 | * |
||
153 | * @param string $uri The target uri |
||
154 | * |
||
155 | * @return bool |
||
156 | * |
||
157 | * @throws InvalidArgumentException |
||
158 | */ |
||
159 | public function redirect(string $uri) :bool |
||
165 | |||
166 | /** |
||
167 | * Set a generic text token which is valid for exactly one call |
||
168 | * |
||
169 | * @param string $key Key for the flash message |
||
170 | * @param string $message Content for the flash message |
||
171 | * |
||
172 | * @return void |
||
173 | */ |
||
174 | public function setFlashMessage(string $key, string $message) |
||
179 | |||
180 | /** |
||
181 | * Retrieve a flash message |
||
182 | * |
||
183 | * @param string $key The flash message key |
||
184 | * |
||
185 | * @return string|null |
||
186 | */ |
||
187 | public function getFlashMessage(string $key) |
||
192 | |||
193 | /** |
||
194 | * Get the url for a specific route name |
||
195 | * |
||
196 | * @param string $name Name of the route |
||
197 | * @param array $parameters Apply parameters where necessary |
||
198 | * @param bool $absolute Return an absolute url with host as prefix |
||
199 | * |
||
200 | * @return string |
||
201 | */ |
||
202 | public function route(string $name, array $parameters = [], bool $absolute = false) |
||
206 | |||
207 | /** |
||
208 | * Return the current request object |
||
209 | * |
||
210 | * @return Request |
||
211 | */ |
||
212 | public function getRequest() :Request |
||
216 | |||
217 | /** |
||
218 | * Add default assets for every action |
||
219 | */ |
||
220 | protected function addAssets() { |
||
223 | |||
224 | } |
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: