1 | <?php |
||
30 | class MiddlewareProcessor |
||
31 | { |
||
32 | /** |
||
33 | * @var FormObject |
||
34 | */ |
||
35 | protected $formObject; |
||
36 | |||
37 | /** |
||
38 | * @var ControllerProcessor |
||
39 | */ |
||
40 | protected $controllerProcessor; |
||
41 | |||
42 | /** |
||
43 | * @var FormResult |
||
44 | */ |
||
45 | protected $result; |
||
46 | |||
47 | /** |
||
48 | * @see getSignalSortedMiddlewares() |
||
49 | * |
||
50 | * @var array |
||
51 | */ |
||
52 | protected $signalSortedMiddlewares = []; |
||
53 | |||
54 | /** |
||
55 | * This context is activated when the request is validating a single field |
||
56 | * and not the whole form. In this case, special behaviours may occur, and |
||
57 | * the processor instance should be aware of it. |
||
58 | * |
||
59 | * @see \Romm\Formz\Middleware\Processor\RemoveFromSingleFieldValidationContext |
||
60 | * |
||
61 | * @var bool |
||
62 | */ |
||
63 | protected $singleFieldValidationContext = false; |
||
64 | |||
65 | /** |
||
66 | * @param FormObject $formObject |
||
67 | * @param ControllerProcessor $controllerProcessor |
||
68 | */ |
||
69 | public function __construct(FormObject $formObject, ControllerProcessor $controllerProcessor) |
||
74 | |||
75 | /** |
||
76 | * Will run and process trough every middleware registered for the current |
||
77 | * form object. |
||
78 | */ |
||
79 | public function run() |
||
96 | |||
97 | /** |
||
98 | * Returns the sorted list of middlewares bound to the given signal name. |
||
99 | * |
||
100 | * @param string $signalName |
||
101 | * @return MiddlewareInterface[] |
||
102 | */ |
||
103 | public function getMiddlewaresBoundToSignal($signalName) |
||
111 | |||
112 | /** |
||
113 | * Returns a sorted list of the registered middlewares: the first level is |
||
114 | * the signal used by the group, and the second level is the group of |
||
115 | * middlewares, sorted by descendant priority of each middleware. |
||
116 | * |
||
117 | * @return array |
||
118 | */ |
||
119 | protected function getSignalSortedMiddlewares() |
||
142 | |||
143 | /** |
||
144 | * @return MiddlewareInterface[] |
||
145 | */ |
||
146 | protected function getFilteredMiddlewares() |
||
160 | |||
161 | /** |
||
162 | * Will sort and return a middlewares list based on the priority of each |
||
163 | * middleware. The middlewares with the highest priority will be placed at |
||
164 | * the top of the list. |
||
165 | * |
||
166 | * @param MiddlewareInterface[] $list |
||
167 | * @return MiddlewareInterface[] |
||
168 | */ |
||
169 | private function sortMiddlewaresListByPriority(array $list) |
||
184 | |||
185 | /** |
||
186 | * @return FormObject |
||
187 | */ |
||
188 | public function getFormObject() |
||
192 | |||
193 | /** |
||
194 | * @return Request |
||
195 | */ |
||
196 | public function getRequest() |
||
200 | |||
201 | /** |
||
202 | * @return Arguments |
||
203 | */ |
||
204 | public function getRequestArguments() |
||
208 | |||
209 | /** |
||
210 | * @return array |
||
211 | */ |
||
212 | public function getSettings() |
||
216 | |||
217 | /** |
||
218 | * @see $singleFieldValidationContext |
||
219 | * |
||
220 | * @return bool |
||
221 | */ |
||
222 | public function inSingleFieldValidationContext() |
||
226 | |||
227 | /** |
||
228 | * @see $singleFieldValidationContext |
||
229 | */ |
||
230 | public function activateSingleFieldValidationContext() |
||
234 | } |
||
235 |