1 | <?php |
||
30 | class FormService implements SingletonInterface |
||
31 | { |
||
32 | /** |
||
33 | * @var bool |
||
34 | */ |
||
35 | protected $formContext = false; |
||
36 | |||
37 | /** |
||
38 | * @var array|FormInterface |
||
39 | */ |
||
40 | protected $formInstance; |
||
41 | |||
42 | /** |
||
43 | * @var bool |
||
44 | */ |
||
45 | protected $formWasSubmitted = false; |
||
46 | |||
47 | /** |
||
48 | * @var FormResult |
||
49 | */ |
||
50 | protected $formResult; |
||
51 | |||
52 | /** |
||
53 | * @var FormObject |
||
54 | */ |
||
55 | protected $formObject; |
||
56 | |||
57 | /** |
||
58 | * Reset every state that can be used by this service. |
||
59 | */ |
||
60 | public function resetState() |
||
67 | |||
68 | /** |
||
69 | * Will activate the form context, changing the result returned by the |
||
70 | * function `formContextExists()`. |
||
71 | * |
||
72 | * @throws \Exception |
||
73 | */ |
||
74 | public function activateFormContext() |
||
85 | |||
86 | /** |
||
87 | * Returns `true` if the `FormViewHelper` context exists. |
||
88 | * |
||
89 | * @return bool |
||
90 | */ |
||
91 | public function formContextExists() |
||
95 | |||
96 | /** |
||
97 | * Will mark the form as submitted (change the result returned by the |
||
98 | * function `formWasSubmitted()`). |
||
99 | */ |
||
100 | public function markFormAsSubmitted() |
||
104 | |||
105 | /** |
||
106 | * Returns `true` if the form was submitted by the user. |
||
107 | * |
||
108 | * @return bool |
||
109 | */ |
||
110 | public function formWasSubmitted() |
||
114 | |||
115 | /** |
||
116 | * Checks that the current `FormViewHelper` exists. If not, an exception is |
||
117 | * thrown. |
||
118 | * |
||
119 | * @throws \Exception |
||
120 | */ |
||
121 | public function checkIsInsideFormViewHelper() |
||
130 | |||
131 | /** |
||
132 | * If the form was submitted by the user, contains the array containing the |
||
133 | * submitted values. |
||
134 | * |
||
135 | * @param array|FormInterface $formInstance |
||
136 | */ |
||
137 | public function setFormInstance($formInstance) |
||
141 | |||
142 | /** |
||
143 | * @return array|FormInterface |
||
144 | */ |
||
145 | public function getFormInstance() |
||
149 | |||
150 | /** |
||
151 | * @return FormResult |
||
152 | */ |
||
153 | public function getFormResult() |
||
157 | |||
158 | /** |
||
159 | * @param FormResult $formResult |
||
160 | */ |
||
161 | public function setFormResult(FormResult $formResult) |
||
165 | |||
166 | /** |
||
167 | * @return FormObject |
||
168 | */ |
||
169 | public function getFormObject() |
||
173 | |||
174 | /** |
||
175 | * @param FormObject $formObject |
||
176 | */ |
||
177 | public function setFormObject(FormObject $formObject) |
||
181 | } |
||
182 |