1 | <?php |
||
33 | class MiddlewareState |
||
34 | { |
||
35 | /** |
||
36 | * @var MiddlewareInterface[] |
||
37 | */ |
||
38 | protected $list = []; |
||
39 | |||
40 | /** |
||
41 | * @var FormObject |
||
42 | */ |
||
43 | protected $formObject; |
||
44 | |||
45 | /** |
||
46 | * @var FormResult |
||
47 | */ |
||
48 | protected $result; |
||
49 | |||
50 | /** |
||
51 | * @var Request |
||
52 | */ |
||
53 | protected $request; |
||
54 | |||
55 | /** |
||
56 | * @var Arguments |
||
57 | */ |
||
58 | protected $arguments; |
||
59 | |||
60 | /** |
||
61 | * @see getSignalSortedMiddlewares() |
||
62 | * |
||
63 | * @var array |
||
64 | */ |
||
65 | protected $signalSortedMiddlewares = []; |
||
66 | |||
67 | /** |
||
68 | * @param FormObject $formObject |
||
69 | * @param FormzControllerContext $formzControllerContext |
||
70 | */ |
||
71 | public function __construct(FormObject $formObject, FormzControllerContext $formzControllerContext) |
||
84 | |||
85 | /** |
||
86 | * Will run and process trough every middleware registered for the current |
||
87 | * form object. |
||
88 | */ |
||
89 | public function run() |
||
99 | |||
100 | /** |
||
101 | * Will dispatch the before-signal from a given source to all middlewares |
||
102 | * bound to the signal. |
||
103 | * |
||
104 | * @param SendsMiddlewareSignal $source |
||
105 | */ |
||
106 | public function dispatchBeforeSignal(SendsMiddlewareSignal $source) |
||
116 | |||
117 | /** |
||
118 | * Will dispatch the after-signal from a given source to all middlewares |
||
119 | * bound to the signal. |
||
120 | * |
||
121 | * @param SendsMiddlewareSignal $source |
||
122 | */ |
||
123 | public function dispatchAfterSignal(SendsMiddlewareSignal $source) |
||
133 | |||
134 | /** |
||
135 | * Returns the sorted list of middlewares bound to the given signal name. |
||
136 | * |
||
137 | * @param string $signalName |
||
138 | * @return array |
||
139 | */ |
||
140 | protected function getMiddlewaresBoundToSignal($signalName) |
||
148 | |||
149 | /** |
||
150 | * Returns a sorted list of the registered middlewares: the first level is |
||
151 | * the signal used by the group, and the second level is the group of |
||
152 | * middlewares, sorted by descendant priority of each middleware. |
||
153 | * |
||
154 | * @return array |
||
155 | */ |
||
156 | protected function getSignalSortedMiddlewares() |
||
179 | |||
180 | /** |
||
181 | * Will sort and return a middlewares list based on the priority of each |
||
182 | * middleware. The middlewares with the highest priority will be placed at |
||
183 | * the top of the list. |
||
184 | * |
||
185 | * @param array $list |
||
186 | * @return array |
||
187 | */ |
||
188 | private function sortMiddlewaresListByPriority(array $list) |
||
205 | |||
206 | /** |
||
207 | * @return FormObject |
||
208 | */ |
||
209 | public function getFormObject() |
||
213 | |||
214 | /** |
||
215 | * @return FormResult |
||
216 | */ |
||
217 | public function getResult() |
||
225 | |||
226 | /** |
||
227 | * @return Request |
||
228 | */ |
||
229 | public function getRequest() |
||
233 | |||
234 | /** |
||
235 | * @return Arguments |
||
236 | */ |
||
237 | public function getArguments() |
||
241 | } |
||
242 |