1 | <?php |
||
27 | class ControllerProcessor implements SingletonInterface |
||
28 | { |
||
29 | use ExtendedSelfInstantiateTrait; |
||
30 | |||
31 | /** |
||
32 | * @var FormObjectFactory |
||
33 | */ |
||
34 | protected $formObjectFactory; |
||
35 | |||
36 | /** |
||
37 | * @var FormObject[] |
||
38 | */ |
||
39 | protected $formArguments; |
||
40 | |||
41 | /** |
||
42 | * @var bool |
||
43 | */ |
||
44 | protected $dispatched = false; |
||
45 | |||
46 | /** |
||
47 | * @var Request |
||
48 | */ |
||
49 | protected $request; |
||
50 | |||
51 | /** |
||
52 | * @var Request |
||
53 | */ |
||
54 | protected $realRequest; |
||
55 | |||
56 | /** |
||
57 | * @var Request |
||
58 | */ |
||
59 | protected $originalRequest; |
||
60 | |||
61 | /** |
||
62 | * @var Arguments |
||
63 | */ |
||
64 | protected $requestArguments; |
||
65 | |||
66 | /** |
||
67 | * @var array |
||
68 | */ |
||
69 | protected $settings = []; |
||
70 | |||
71 | /** |
||
72 | * @param MvcRequest $request |
||
73 | * @param Arguments $requestArguments |
||
74 | * @param array $settings |
||
75 | * @return $this |
||
76 | */ |
||
77 | public static function prepare(MvcRequest $request, Arguments $requestArguments, array $settings) |
||
81 | |||
82 | /** |
||
83 | * Injects the data needed for this class to work properly. This method must |
||
84 | * be called before the dispatch is called. |
||
85 | * |
||
86 | * @param MvcRequest $request |
||
87 | * @param Arguments $requestArguments |
||
88 | * @param array $settings |
||
89 | * @return $this |
||
90 | */ |
||
91 | public function setData(MvcRequest $request, Arguments $requestArguments, array $settings) |
||
102 | |||
103 | /** |
||
104 | * Will dispatch the current request to the form controller, which will take |
||
105 | * care of processing everything properly. |
||
106 | * |
||
107 | * In case no form is found in the controller action parameters, the current |
||
108 | * request is not killed. |
||
109 | * |
||
110 | * @throws StopActionException |
||
111 | */ |
||
112 | public function dispatch() |
||
133 | |||
134 | /** |
||
135 | * Will check if the form objects found in the request arguments contain |
||
136 | * configuration errors. If they do, we dispatch the request to the error |
||
137 | * view, where all errors will be explained properly to the user. |
||
138 | */ |
||
139 | protected function checkFormObjectsErrors() |
||
150 | |||
151 | /** |
||
152 | * Loops on the request arguments, and pick up each one that is a form |
||
153 | * instance (it implements `FormInterface`). |
||
154 | * |
||
155 | * @return FormObject[] |
||
156 | */ |
||
157 | public function getRequestForms() |
||
180 | |||
181 | /** |
||
182 | * @return Request |
||
183 | */ |
||
184 | public function getRequest() |
||
188 | |||
189 | /** |
||
190 | * @return Arguments |
||
191 | */ |
||
192 | public function getRequestArguments() |
||
196 | |||
197 | /** |
||
198 | * @return array |
||
199 | */ |
||
200 | public function getSettings() |
||
204 | |||
205 | /** |
||
206 | * @param FormObjectFactory $formObjectFactory |
||
207 | */ |
||
208 | public function injectFormObjectFactory(FormObjectFactory $formObjectFactory) |
||
212 | } |
||
213 |