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 | * @return FormViewHelperService |
||
76 | * @throws DuplicateEntryException |
||
77 | */ |
||
78 | public function activateFormContext() |
||
88 | |||
89 | /** |
||
90 | * Returns `true` if the `FormViewHelper` context exists. |
||
91 | * |
||
92 | * @return bool |
||
93 | */ |
||
94 | public function formContextExists() |
||
98 | |||
99 | /** |
||
100 | * This function will check and inject the form instance and its submission |
||
101 | * result. |
||
102 | * |
||
103 | * @param string $formName |
||
104 | * @param Request $originalRequest |
||
105 | * @param array|FormInterface $formInstance |
||
106 | */ |
||
107 | public function setUpData($formName, $originalRequest, $formInstance) |
||
126 | |||
127 | /** |
||
128 | * Will mark the form as submitted (change the result returned by the |
||
129 | * function `formWasSubmitted()`). |
||
130 | */ |
||
131 | public function markFormAsSubmitted() |
||
135 | |||
136 | /** |
||
137 | * Returns `true` if the form was submitted by the user. |
||
138 | * |
||
139 | * @return bool |
||
140 | */ |
||
141 | public function formWasSubmitted() |
||
145 | |||
146 | /** |
||
147 | * @return array|FormInterface |
||
148 | */ |
||
149 | public function getFormInstance() |
||
153 | |||
154 | /** |
||
155 | * If the form was submitted by the user, contains the array containing the |
||
156 | * submitted values. |
||
157 | * |
||
158 | * @param array|FormInterface $formInstance |
||
159 | */ |
||
160 | public function setFormInstance($formInstance) |
||
164 | |||
165 | /** |
||
166 | * @return FormResult |
||
167 | */ |
||
168 | public function getFormResult() |
||
172 | |||
173 | /** |
||
174 | * @param FormResult $formResult |
||
175 | */ |
||
176 | public function setFormResult(FormResult $formResult) |
||
180 | |||
181 | /** |
||
182 | * @return FormObject |
||
183 | */ |
||
184 | public function getFormObject() |
||
188 | |||
189 | /** |
||
190 | * @param FormObject $formObject |
||
191 | */ |
||
192 | public function setFormObject(FormObject $formObject) |
||
196 | |||
197 | /** |
||
198 | * @param string $formName |
||
199 | * @return DefaultFormValidator |
||
200 | */ |
||
201 | protected function getFormValidator($formName) |
||
205 | } |
||
206 |
This check looks at variables that have been passed in as parameters and are passed out again to other methods.
If the outgoing method call has stricter type requirements than the method itself, an issue is raised.
An additional type check may prevent trouble.