1 | <?php |
||
32 | class FormViewHelperService implements SingletonInterface |
||
33 | { |
||
34 | /** |
||
35 | * @var bool |
||
36 | */ |
||
37 | protected $formContext = false; |
||
38 | |||
39 | /** |
||
40 | * @var array|FormInterface |
||
41 | */ |
||
42 | protected $formInstance; |
||
43 | |||
44 | /** |
||
45 | * @var bool |
||
46 | */ |
||
47 | protected $formWasSubmitted = false; |
||
48 | |||
49 | /** |
||
50 | * @var FormResult |
||
51 | */ |
||
52 | protected $formResult; |
||
53 | |||
54 | /** |
||
55 | * @var FormObject |
||
56 | */ |
||
57 | protected $formObject; |
||
58 | |||
59 | /** |
||
60 | * Reset every state that can be used by this service. |
||
61 | */ |
||
62 | public function resetState() |
||
70 | |||
71 | /** |
||
72 | * Will activate the form context, changing the result returned by the |
||
73 | * function `formContextExists()`. |
||
74 | * |
||
75 | * @throws \Exception |
||
76 | * @return FormViewHelperService |
||
77 | */ |
||
78 | public function activateFormContext() |
||
91 | |||
92 | /** |
||
93 | * Returns `true` if the `FormViewHelper` context exists. |
||
94 | * |
||
95 | * @return bool |
||
96 | */ |
||
97 | public function formContextExists() |
||
101 | |||
102 | /** |
||
103 | * This function will check and inject the form instance and its submission |
||
104 | * result. |
||
105 | * |
||
106 | * @param string $formName |
||
107 | * @param Request $originalRequest |
||
108 | * @param $formInstance |
||
109 | */ |
||
110 | public function setUpData($formName, $originalRequest, $formInstance) |
||
129 | |||
130 | /** |
||
131 | * Will mark the form as submitted (change the result returned by the |
||
132 | * function `formWasSubmitted()`). |
||
133 | */ |
||
134 | public function markFormAsSubmitted() |
||
138 | |||
139 | /** |
||
140 | * Returns `true` if the form was submitted by the user. |
||
141 | * |
||
142 | * @return bool |
||
143 | */ |
||
144 | public function formWasSubmitted() |
||
148 | |||
149 | /** |
||
150 | * @return array|FormInterface |
||
151 | */ |
||
152 | public function getFormInstance() |
||
156 | |||
157 | /** |
||
158 | * If the form was submitted by the user, contains the array containing the |
||
159 | * submitted values. |
||
160 | * |
||
161 | * @param array|FormInterface $formInstance |
||
162 | */ |
||
163 | public function setFormInstance($formInstance) |
||
167 | |||
168 | /** |
||
169 | * @return FormResult |
||
170 | */ |
||
171 | public function getFormResult() |
||
175 | |||
176 | /** |
||
177 | * @param FormResult $formResult |
||
178 | */ |
||
179 | public function setFormResult(FormResult $formResult) |
||
183 | |||
184 | /** |
||
185 | * @return FormObject |
||
186 | */ |
||
187 | public function getFormObject() |
||
191 | |||
192 | /** |
||
193 | * @param FormObject $formObject |
||
194 | */ |
||
195 | public function setFormObject(FormObject $formObject) |
||
199 | |||
200 | /** |
||
201 | * @param string $formName |
||
202 | * @return DefaultFormValidator |
||
203 | */ |
||
204 | protected function getFormValidator($formName) |
||
208 | } |
||
209 |