1 | <?php |
||
8 | class FormComponent Extends BaseComponent |
||
9 | { |
||
10 | /** |
||
11 | * @var null|string |
||
12 | */ |
||
13 | protected $documentType = null; |
||
14 | /** |
||
15 | * @var null|string |
||
16 | */ |
||
17 | protected $responseFolder = null; |
||
18 | /** |
||
19 | * @var string |
||
20 | */ |
||
21 | protected $subTemplate = 'cms/documents/document-form-form'; |
||
22 | /** |
||
23 | * @var string |
||
24 | */ |
||
25 | protected $formParameterName = 'form'; |
||
26 | /** |
||
27 | * @var string |
||
28 | */ |
||
29 | protected $thankYouMessage = 'Thank you for sending us your response.'; |
||
30 | |||
31 | /** |
||
32 | * @var bool |
||
33 | */ |
||
34 | protected $submitOncePerSession = false; |
||
35 | |||
36 | /** |
||
37 | * @var string |
||
38 | */ |
||
39 | private $formId; |
||
40 | /** |
||
41 | * @var null|string |
||
42 | */ |
||
43 | private $getPathBackup = null; |
||
44 | |||
45 | /** |
||
46 | * @var null|\stdClass |
||
47 | */ |
||
48 | private $userSessionBackup = null; |
||
49 | |||
50 | /** |
||
51 | * @param Storage $storage |
||
52 | * @return void |
||
53 | * @throws \Exception |
||
54 | */ |
||
55 | public function run(Storage $storage) |
||
69 | |||
70 | /** |
||
71 | * @param null|Application $application |
||
72 | * @throws \Exception |
||
73 | */ |
||
74 | public function render($application = null) |
||
95 | |||
96 | /** |
||
97 | * Checks if parameters were given in the CMS configuration and |
||
98 | * sets them to their respective fields |
||
99 | */ |
||
100 | private function checkParameters() |
||
132 | |||
133 | /** |
||
134 | * Sets variables needed for rendering the form template |
||
135 | * @param $storage |
||
136 | */ |
||
137 | private function initialize($storage) |
||
147 | |||
148 | /** |
||
149 | * If the form has been submitted, save the document |
||
150 | * Calls $this->postSubmit() afterwards |
||
151 | * |
||
152 | * @param Storage $storage |
||
153 | */ |
||
154 | private function checkSubmit($storage) |
||
165 | |||
166 | /** |
||
167 | * Hook for derived classes to take actions after |
||
168 | * submitting the form |
||
169 | * |
||
170 | * @param $postValues |
||
171 | * @param $storage |
||
172 | */ |
||
173 | protected function postSubmit($postValues, $storage) |
||
175 | |||
176 | /** |
||
177 | * Sets a unique id for this particular form, so it can recognize |
||
178 | * it when a submit occurs |
||
179 | */ |
||
180 | private function setFormId() |
||
190 | |||
191 | /** |
||
192 | * Checks if this form has been submitted |
||
193 | * |
||
194 | * @param $request |
||
195 | * @return bool |
||
196 | */ |
||
197 | private function isFormSubmitted($request) |
||
201 | |||
202 | /** |
||
203 | * |
||
204 | * |
||
205 | * @param $request |
||
206 | */ |
||
207 | private function getPostValues($request) |
||
215 | |||
216 | /** |
||
217 | * Temporarily stores the current user session in a backup variable |
||
218 | * and sets a fake user instead |
||
219 | */ |
||
220 | private function setUserSessionBackup() |
||
227 | |||
228 | /** |
||
229 | * Removes the fake user and restores the existing user |
||
230 | * session if it was there |
||
231 | */ |
||
232 | private function restoreUserSessionBackup() |
||
240 | |||
241 | private function setSubmitToSession() |
||
245 | |||
246 | private function isSubmitAllowed() |
||
254 | } |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.