1 | <?php |
||
31 | class FormzViewHelperService implements SingletonInterface |
||
32 | { |
||
33 | /** |
||
34 | * @var bool |
||
35 | */ |
||
36 | protected $formContext; |
||
37 | |||
38 | /** |
||
39 | * @var array|FormInterface |
||
40 | */ |
||
41 | protected $formInstance; |
||
42 | |||
43 | /** |
||
44 | * @var Field |
||
45 | */ |
||
46 | protected $currentField; |
||
47 | |||
48 | /** |
||
49 | * @var bool |
||
50 | */ |
||
51 | protected $formWasSubmitted; |
||
52 | |||
53 | /** |
||
54 | * @var FormResult |
||
55 | */ |
||
56 | protected $formResult; |
||
57 | |||
58 | /** |
||
59 | * @var FormObject |
||
60 | */ |
||
61 | protected $formObject; |
||
62 | |||
63 | /** |
||
64 | * @var array |
||
65 | */ |
||
66 | protected $fieldOptions = []; |
||
67 | |||
68 | /** |
||
69 | * Reset every state that can be used by this service. |
||
70 | */ |
||
71 | public function resetState() |
||
79 | |||
80 | /** |
||
81 | * Will activate the form context, changing the result returned by the |
||
82 | * function `formContextExists`. |
||
83 | * |
||
84 | * @throws \Exception |
||
85 | */ |
||
86 | public function activateFormContext() |
||
97 | |||
98 | /** |
||
99 | * Returns `true` if the `FormViewHelper` context exists. |
||
100 | * |
||
101 | * @return bool |
||
102 | */ |
||
103 | public function formContextExists() |
||
107 | |||
108 | /** |
||
109 | * Will mark the form as submitted (change the result returned by the |
||
110 | * function `formWasSubmitted()`). |
||
111 | */ |
||
112 | public function markFormAsSubmitted() |
||
116 | |||
117 | /** |
||
118 | * Returns `true` if the form was submitted by the user. |
||
119 | * |
||
120 | * @return bool |
||
121 | */ |
||
122 | public function formWasSubmitted() |
||
126 | |||
127 | /** |
||
128 | * Checks that the `FieldViewHelper` has been called. If not, an exception |
||
129 | * is thrown. |
||
130 | * |
||
131 | * @return bool |
||
132 | */ |
||
133 | public function fieldContextExists() |
||
137 | |||
138 | /** |
||
139 | * Returns the current field which was defined by the `FieldViewHelper`. |
||
140 | * |
||
141 | * Returns null if no current field was found. |
||
142 | * |
||
143 | * @return Field|null |
||
144 | */ |
||
145 | public function getCurrentField() |
||
149 | |||
150 | /** |
||
151 | * @param Field $field |
||
152 | */ |
||
153 | public function setCurrentField(Field $field) |
||
157 | |||
158 | /** |
||
159 | * @param string $name |
||
160 | * @param mixed $value |
||
161 | */ |
||
162 | public function setFieldOption($name, $value) |
||
166 | |||
167 | /** |
||
168 | * @return array |
||
169 | */ |
||
170 | public function getFieldOptions() |
||
174 | |||
175 | /** |
||
176 | * @return $this |
||
177 | */ |
||
178 | public function resetFieldOptions() |
||
184 | |||
185 | /** |
||
186 | * Unset the current field. |
||
187 | * |
||
188 | * @return $this |
||
189 | */ |
||
190 | public function removeCurrentField() |
||
196 | |||
197 | /** |
||
198 | * Checks that the current `FormViewHelper` exists. If not, an exception is |
||
199 | * thrown. |
||
200 | * |
||
201 | * @throws \Exception |
||
202 | */ |
||
203 | public function checkIsInsideFormViewHelper() |
||
212 | |||
213 | /** |
||
214 | * Checks that the `FieldViewHelper` has been called. If not, an exception |
||
215 | * is thrown. |
||
216 | * |
||
217 | * @throws \Exception |
||
218 | */ |
||
219 | public function checkIsInsideFieldViewHelper() |
||
228 | |||
229 | /** |
||
230 | * If the form was submitted by the user, contains the array containing the |
||
231 | * submitted values. |
||
232 | * |
||
233 | * @param array|FormInterface $formInstance |
||
234 | */ |
||
235 | public function setFormInstance($formInstance) |
||
239 | |||
240 | /** |
||
241 | * @return array|FormInterface |
||
242 | */ |
||
243 | public function getFormInstance() |
||
247 | |||
248 | /** |
||
249 | * @return FormResult |
||
250 | */ |
||
251 | public function getFormResult() |
||
255 | |||
256 | /** |
||
257 | * @param FormResult $formResult |
||
258 | */ |
||
259 | public function setFormResult(FormResult $formResult) |
||
263 | |||
264 | /** |
||
265 | * @return FormObject |
||
266 | */ |
||
267 | public function getFormObject() |
||
271 | |||
272 | /** |
||
273 | * @param FormObject $formObject |
||
274 | */ |
||
275 | public function setFormObject(FormObject $formObject) |
||
279 | } |
||
280 |