1 | <?php |
||
28 | class ControllerProcessor implements SingletonInterface |
||
29 | { |
||
30 | use ExtendedSelfInstantiateTrait; |
||
31 | |||
32 | /** |
||
33 | * @var FormObjectFactory |
||
34 | */ |
||
35 | protected $formObjectFactory; |
||
36 | |||
37 | /** |
||
38 | * @var FormObject[] |
||
39 | */ |
||
40 | protected $formArguments; |
||
41 | |||
42 | /** |
||
43 | * @var bool |
||
44 | */ |
||
45 | protected $dispatched = false; |
||
46 | |||
47 | /** |
||
48 | * @var Request |
||
49 | */ |
||
50 | protected $originalRequest; |
||
51 | |||
52 | /** |
||
53 | * @var Request |
||
54 | */ |
||
55 | protected $request; |
||
56 | |||
57 | /** |
||
58 | * @var Arguments |
||
59 | */ |
||
60 | protected $requestArguments; |
||
61 | |||
62 | /** |
||
63 | * An interface name that does implement: |
||
64 | * |
||
65 | * @see \Romm\Formz\Middleware\Scope\ScopeInterface |
||
66 | * |
||
67 | * It will be used to filter the middlewares that will be called. |
||
68 | * |
||
69 | * @var string |
||
70 | */ |
||
71 | protected $scope; |
||
72 | |||
73 | /** |
||
74 | * @var array |
||
75 | */ |
||
76 | protected $settings = []; |
||
77 | |||
78 | /** |
||
79 | * Contains information about the last request that was dispatched to FormZ. |
||
80 | * It is used to prevent infinite loop. |
||
81 | * |
||
82 | * @var string |
||
83 | */ |
||
84 | protected $lastDispatchedRequest; |
||
85 | |||
86 | /** |
||
87 | * @var callable |
||
88 | */ |
||
89 | protected $exceptionCallback; |
||
90 | |||
91 | /** |
||
92 | * @param MvcRequest $request |
||
93 | * @param Arguments $requestArguments |
||
94 | * @param string $scope |
||
95 | * @return $this |
||
96 | */ |
||
97 | public static function prepare(MvcRequest $request, Arguments $requestArguments, $scope) |
||
101 | |||
102 | /** |
||
103 | * Injects the data needed for this class to work properly. This method must |
||
104 | * be called before the `dispatch` method is called. |
||
105 | * |
||
106 | * @param MvcRequest $request |
||
107 | * @param Arguments $requestArguments |
||
108 | * @param string $scope |
||
109 | * @param array $settings |
||
110 | * @return $this |
||
111 | */ |
||
112 | public function setData(MvcRequest $request, Arguments $requestArguments, $scope, array $settings) |
||
135 | |||
136 | /** |
||
137 | * Will dispatch the current request to the form controller, which will take |
||
138 | * care of processing everything properly. |
||
139 | * |
||
140 | * In case no form is found in the controller action parameters, the current |
||
141 | * request is not killed. |
||
142 | * |
||
143 | * @throws StopActionException |
||
144 | */ |
||
145 | public function dispatch() |
||
153 | |||
154 | /** |
||
155 | * Wrapper for unit testing. |
||
156 | */ |
||
157 | protected function doDispatch() |
||
171 | |||
172 | /** |
||
173 | * Will check if the form objects found in the request arguments contain |
||
174 | * configuration errors. If they do, we dispatch the request to the error |
||
175 | * view, where all errors will be explained properly to the user. |
||
176 | */ |
||
177 | protected function checkFormObjectsErrors() |
||
188 | |||
189 | /** |
||
190 | * Loops on the request arguments, and picks up each one that is a form |
||
191 | * instance (it implements `FormInterface`). |
||
192 | * |
||
193 | * @return FormObject[] |
||
194 | */ |
||
195 | public function getRequestForms() |
||
218 | |||
219 | /** |
||
220 | * @return Request |
||
221 | */ |
||
222 | public function getRequest() |
||
226 | |||
227 | /** |
||
228 | * @return Arguments |
||
229 | */ |
||
230 | public function getRequestArguments() |
||
234 | |||
235 | /** |
||
236 | * @return array |
||
237 | */ |
||
238 | public function getSettings() |
||
242 | |||
243 | /** |
||
244 | * @return string |
||
245 | */ |
||
246 | public function getScope() |
||
250 | |||
251 | /** |
||
252 | * @param callable $callback |
||
253 | * @return $this |
||
254 | */ |
||
255 | public function setExceptionCallback(callable $callback) |
||
261 | |||
262 | /** |
||
263 | * @return callable |
||
264 | */ |
||
265 | public function getExceptionCallback() |
||
269 | |||
270 | /** |
||
271 | * @return bool |
||
272 | */ |
||
273 | public function hasExceptionCallback() |
||
277 | |||
278 | /** |
||
279 | * @param FormObjectFactory $formObjectFactory |
||
280 | */ |
||
281 | public function injectFormObjectFactory(FormObjectFactory $formObjectFactory) |
||
285 | } |
||
286 |
This check looks for methods that are used by a trait but not required by it.
To illustrate, let’s look at the following code example
The trait
Idable
provides a methodequalsId
that in turn relies on the methodgetId()
. If this method does not exist on a class mixing in this trait, the method will fail.Adding the
getId()
as an abstract method to the trait will make sure it is available.