1 | <?php |
||
36 | class StepMiddlewareService implements SingletonInterface |
||
37 | { |
||
38 | use SelfInstantiateTrait; |
||
39 | |||
40 | /** |
||
41 | * @var FormObject |
||
42 | */ |
||
43 | protected $formObject; |
||
44 | |||
45 | /** |
||
46 | * @var Request |
||
47 | */ |
||
48 | protected $request; |
||
49 | |||
50 | /** |
||
51 | * @var StepMiddlewareValidationService |
||
52 | */ |
||
53 | protected $validationService; |
||
54 | |||
55 | /** |
||
56 | * @var FormStepPersistence |
||
57 | */ |
||
58 | protected $persistence; |
||
59 | |||
60 | /** |
||
61 | * @param FormObject $formObject |
||
62 | * @param Request $request |
||
63 | */ |
||
64 | public function reset(FormObject $formObject, Request $request) |
||
73 | |||
74 | /** |
||
75 | * @param Step $currentStep |
||
76 | * @return StepDefinition|null |
||
77 | */ |
||
78 | public function getNextStep(Step $currentStep) |
||
98 | |||
99 | /** |
||
100 | * Saves the submitted values in the metadata, for the given step. |
||
101 | * |
||
102 | * @param Step $currentStep |
||
103 | */ |
||
104 | public function saveStepFormValues(Step $currentStep) |
||
108 | |||
109 | /** |
||
110 | * Fetches the raw values sent in the request. |
||
111 | * |
||
112 | * @return array |
||
113 | * @throws InvalidArgumentTypeException |
||
114 | */ |
||
115 | protected function getFormRawValues() |
||
133 | |||
134 | /** |
||
135 | * @see \Romm\Formz\Middleware\Item\Step\Service\StepMiddlewareValidationService::markStepAsValidated |
||
136 | * |
||
137 | * @param StepDefinition $stepDefinition |
||
138 | * @param array $formValues |
||
139 | */ |
||
140 | public function markStepAsValidated(StepDefinition $stepDefinition, array $formValues) |
||
144 | |||
145 | /** |
||
146 | * @see \Romm\Formz\Middleware\Item\Step\Service\StepMiddlewareValidationService::addValidatedFields |
||
147 | * |
||
148 | * @param array $validatedFields |
||
149 | */ |
||
150 | public function addValidatedFields(array $validatedFields) |
||
154 | |||
155 | /** |
||
156 | * @see \Romm\Formz\Middleware\Item\Step\Service\StepMiddlewareValidationService::stepDefinitionIsValid |
||
157 | * |
||
158 | * @param StepDefinition $stepDefinition |
||
159 | * @return bool |
||
160 | */ |
||
161 | public function stepIsValid(StepDefinition $stepDefinition) |
||
165 | |||
166 | /** |
||
167 | * @see \Romm\Formz\Middleware\Item\Step\Service\StepMiddlewareValidationService::getFirstInvalidStep |
||
168 | * |
||
169 | * @param Step $step |
||
170 | * @return StepDefinition|null |
||
171 | */ |
||
172 | public function getFirstInvalidStep(Step $step) |
||
176 | |||
177 | /** |
||
178 | * @param StepDefinition $step |
||
179 | * @param bool $removeConditionalSteps |
||
180 | * @return StepDefinition |
||
181 | */ |
||
182 | public function getNextStepDefinition(StepDefinition $step, $removeConditionalSteps = false) |
||
217 | |||
218 | /** |
||
219 | * @param StepDefinition $stepDefinition |
||
220 | * @param Redirect $redirect |
||
221 | */ |
||
222 | public function moveForwardToStep(StepDefinition $stepDefinition, Redirect $redirect) |
||
227 | |||
228 | /** |
||
229 | * Redirects the current request to the given step. |
||
230 | * |
||
231 | * @param Step $step |
||
232 | * @param Redirect $redirect |
||
233 | */ |
||
234 | public function redirectToStep(Step $step, Redirect $redirect) |
||
247 | |||
248 | /** |
||
249 | * @param StepDefinition $stepDefinition |
||
250 | * @return bool |
||
251 | */ |
||
252 | public function getStepDefinitionConditionResult(StepDefinition $stepDefinition) |
||
261 | |||
262 | /** |
||
263 | * @param Step $step |
||
264 | * @return StepDefinition|null |
||
265 | */ |
||
266 | public function getStepDefinition(Step $step) |
||
270 | |||
271 | /** |
||
272 | * @param Step $step |
||
273 | * @param StepDefinition $stepDefinition |
||
274 | * @return StepDefinition|null |
||
275 | */ |
||
276 | protected function findStepDefinition(Step $step, StepDefinition $stepDefinition) |
||
302 | |||
303 | /** |
||
304 | * @return FormStepPersistence |
||
305 | */ |
||
306 | public function getStepPersistence() |
||
310 | |||
311 | /** |
||
312 | * @return FormObject |
||
313 | */ |
||
314 | public function getFormObject() |
||
318 | |||
319 | /** |
||
320 | * @return StepDefinition |
||
321 | */ |
||
322 | public function getFirstStepDefinition() |
||
326 | } |
||
327 |
Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code: