1 | <?php |
||
31 | class FormzViewHelperService implements SingletonInterface |
||
32 | { |
||
33 | |||
34 | /** |
||
35 | * @var FormzViewHelperService |
||
36 | */ |
||
37 | protected static $instance; |
||
38 | |||
39 | /** |
||
40 | * @var bool |
||
41 | */ |
||
42 | protected $formContext; |
||
43 | |||
44 | /** |
||
45 | * @var array|FormInterface |
||
46 | */ |
||
47 | protected $formInstance; |
||
48 | |||
49 | /** |
||
50 | * @var Field |
||
51 | */ |
||
52 | protected $currentField; |
||
53 | |||
54 | /** |
||
55 | * @var bool |
||
56 | */ |
||
57 | protected $formWasSubmitted; |
||
58 | |||
59 | /** |
||
60 | * @var FormResult |
||
61 | */ |
||
62 | protected $formResult; |
||
63 | |||
64 | /** |
||
65 | * @var FormObject |
||
66 | */ |
||
67 | protected $formObject; |
||
68 | |||
69 | /** |
||
70 | * Reset every state that can be used by this service. |
||
71 | */ |
||
72 | public function resetState() |
||
80 | |||
81 | /** |
||
82 | * Will activate the form context, changing the result returned by the |
||
83 | * function `formContextExists`. |
||
84 | * |
||
85 | * @throws \Exception |
||
86 | */ |
||
87 | public function activateFormContext() |
||
98 | |||
99 | /** |
||
100 | * Returns `true` if the `FormViewHelper` context exists. |
||
101 | * |
||
102 | * @return bool |
||
103 | */ |
||
104 | public function formContextExists() |
||
108 | |||
109 | /** |
||
110 | * Will mark the form as submitted (change the result returned by the |
||
111 | * function `formWasSubmitted()`). |
||
112 | */ |
||
113 | public function markFormAsSubmitted() |
||
117 | |||
118 | /** |
||
119 | * Returns `true` if the form was submitted by the user. |
||
120 | * |
||
121 | * @return bool |
||
122 | */ |
||
123 | public function formWasSubmitted() |
||
127 | |||
128 | /** |
||
129 | * Checks that the `FieldViewHelper` has been called. If not, an exception |
||
130 | * is thrown. |
||
131 | * |
||
132 | * @return bool |
||
133 | */ |
||
134 | public function fieldContextExists() |
||
138 | |||
139 | /** |
||
140 | * Returns the current field which was defined by the `FieldViewHelper`. |
||
141 | * |
||
142 | * Returns null if no current field was found. |
||
143 | * |
||
144 | * @return Field|null |
||
145 | */ |
||
146 | public function getCurrentField() |
||
150 | |||
151 | /** |
||
152 | * @param Field $field |
||
153 | */ |
||
154 | public function setCurrentField(Field $field) |
||
158 | |||
159 | /** |
||
160 | * Unset the current field. |
||
161 | */ |
||
162 | public function removeCurrentField() |
||
166 | |||
167 | /** |
||
168 | * Checks that the current `FormViewHelper` exists. If not, an exception is |
||
169 | * thrown. |
||
170 | * |
||
171 | * @throws \Exception |
||
172 | */ |
||
173 | public function checkIsInsideFormViewHelper() |
||
182 | |||
183 | /** |
||
184 | * Checks that the `FieldViewHelper` has been called. If not, an exception |
||
185 | * is thrown. |
||
186 | * |
||
187 | * @throws \Exception |
||
188 | */ |
||
189 | public function checkIsInsideFieldViewHelper() |
||
198 | |||
199 | /** |
||
200 | * If the form was submitted by the user, contains the array containing the |
||
201 | * submitted values. |
||
202 | * |
||
203 | * @param array|FormInterface $formInstance |
||
204 | */ |
||
205 | public function setFormInstance($formInstance) |
||
209 | |||
210 | /** |
||
211 | * @return array|FormInterface |
||
212 | */ |
||
213 | public function getFormInstance() |
||
217 | |||
218 | /** |
||
219 | * @return FormResult |
||
220 | */ |
||
221 | public function getFormResult() |
||
225 | |||
226 | /** |
||
227 | * @param FormResult $formResult |
||
228 | */ |
||
229 | public function setFormResult(FormResult $formResult) |
||
233 | |||
234 | /** |
||
235 | * @return FormObject |
||
236 | */ |
||
237 | public function getFormObject() |
||
241 | |||
242 | /** |
||
243 | * @param FormObject $formObject |
||
244 | */ |
||
245 | public function setFormObject(FormObject $formObject) |
||
249 | } |
||
250 |