1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Kunstmaan\FormBundle\Entity; |
4
|
|
|
|
5
|
|
|
use Doctrine\ORM\Mapping as ORM; |
6
|
|
|
use Symfony\Component\DependencyInjection\ContainerInterface; |
7
|
|
|
use Symfony\Component\Form\Form; |
8
|
|
|
use Symfony\Component\Form\FormBuilderInterface; |
9
|
|
|
use Symfony\Component\HttpFoundation\Request; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* The FormSubmissionField will hold the submitted values from the form page parts. The FormSubmissionFields |
13
|
|
|
* will be attached to a FormSubmission. |
14
|
|
|
* |
15
|
|
|
* @ORM\Entity |
16
|
|
|
* @ORM\Table(name="kuma_form_submission_fields") |
17
|
|
|
* @ORM\InheritanceType("SINGLE_TABLE") |
18
|
|
|
* @ORM\DiscriminatorColumn(name="discr", type="string") |
19
|
|
|
*/ |
20
|
|
|
abstract class FormSubmissionField |
21
|
|
|
{ |
22
|
|
|
/** |
23
|
|
|
* This id of this FormSubmissionField |
24
|
|
|
* |
25
|
|
|
* @ORM\Id |
26
|
|
|
* @ORM\Column(type="bigint") |
27
|
|
|
* @ORM\GeneratedValue(strategy="AUTO") |
28
|
|
|
*/ |
29
|
|
|
protected $id; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* The name of this FormSubmissionField |
33
|
|
|
* |
34
|
|
|
* @ORM\Column(type="string") |
35
|
|
|
*/ |
36
|
|
|
protected $fieldName; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* The label used for this FormSubmissionField |
40
|
|
|
* |
41
|
|
|
* @ORM\Column(type="string") |
42
|
|
|
*/ |
43
|
|
|
protected $label; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* The FormSubmission this field is part of |
47
|
|
|
* |
48
|
|
|
* @ORM\ManyToOne(targetEntity="FormSubmission", inversedBy="fields") |
49
|
|
|
* @ORM\JoinColumn(name="form_submission_id", referencedColumnName="id") |
50
|
|
|
*/ |
51
|
|
|
protected $formSubmission; |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @ORM\Column(type="integer", nullable=true) |
55
|
|
|
*/ |
56
|
|
|
protected $sequence; |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* The internal name of the form pagepart attached to this. |
60
|
|
|
* |
61
|
|
|
* @ORM\Column(name="internal_name", type="string", nullable=true) |
62
|
|
|
*/ |
63
|
|
|
protected $internalName; |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* Get id |
67
|
|
|
* |
68
|
|
|
* @return integer |
|
|
|
|
69
|
|
|
*/ |
70
|
|
|
public function getId() |
71
|
|
|
{ |
72
|
|
|
return $this->id; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* Set id |
77
|
|
|
* |
78
|
|
|
* @param string $id |
79
|
|
|
* |
80
|
|
|
* @return FormSubmissionField |
81
|
|
|
*/ |
82
|
|
|
public function setId($id) |
83
|
|
|
{ |
84
|
|
|
$this->id = $id; |
85
|
|
|
|
86
|
|
|
return $this; |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* Get the field name |
91
|
|
|
* |
92
|
|
|
* @return string |
93
|
|
|
*/ |
94
|
|
|
public function getFieldName() |
95
|
|
|
{ |
96
|
|
|
return $this->fieldName; |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* Set the field name |
101
|
|
|
* |
102
|
|
|
* @param string $fieldName |
103
|
|
|
* |
104
|
|
|
* @return FormSubmissionField |
105
|
|
|
*/ |
106
|
|
|
public function setFieldName($fieldName) |
107
|
|
|
{ |
108
|
|
|
$this->fieldName = $fieldName; |
109
|
|
|
|
110
|
|
|
return $this; |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
/** |
114
|
|
|
* Get the label |
115
|
|
|
* |
116
|
|
|
* @return string |
117
|
|
|
*/ |
118
|
|
|
public function getLabel() |
119
|
|
|
{ |
120
|
|
|
return $this->label; |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
/** |
124
|
|
|
* Set the label |
125
|
|
|
* |
126
|
|
|
* @param string $label |
127
|
|
|
* |
128
|
|
|
* @return FormSubmissionField |
129
|
|
|
*/ |
130
|
|
|
public function setLabel($label) |
131
|
|
|
{ |
132
|
|
|
$this->label = $label; |
133
|
|
|
|
134
|
|
|
return $this; |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
/** |
138
|
|
|
* Get the FormSubmission this field is part of |
139
|
|
|
* |
140
|
|
|
* @return FormSubmission |
141
|
|
|
*/ |
142
|
|
|
public function getSubmission() |
143
|
|
|
{ |
144
|
|
|
return $this->formSubmission; |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
/** |
148
|
|
|
* Set the FormSubmission this field is part of |
149
|
|
|
* |
150
|
|
|
* @param FormSubmission $formSubmission |
151
|
|
|
* |
152
|
|
|
* @return FormSubmissionField |
153
|
|
|
*/ |
154
|
|
|
public function setSubmission(FormSubmission $formSubmission) |
155
|
|
|
{ |
156
|
|
|
$this->formSubmission = $formSubmission; |
157
|
|
|
|
158
|
|
|
return $this; |
159
|
|
|
} |
160
|
|
|
|
161
|
|
|
/** |
162
|
|
|
* Get sequence |
163
|
|
|
* |
164
|
|
|
* @return integer |
|
|
|
|
165
|
|
|
*/ |
166
|
|
|
public function getSequence() |
167
|
|
|
{ |
168
|
|
|
return $this->sequence; |
169
|
|
|
} |
170
|
|
|
|
171
|
|
|
/** |
172
|
|
|
* Set sequence |
173
|
|
|
* |
174
|
|
|
* @param string $sequence |
175
|
|
|
* |
176
|
|
|
* @return FormSubmissionField |
177
|
|
|
*/ |
178
|
|
|
public function setSequence($sequence) |
179
|
|
|
{ |
180
|
|
|
$this->sequence = $sequence; |
181
|
|
|
|
182
|
|
|
return $this; |
183
|
|
|
} |
184
|
|
|
|
185
|
|
|
/** |
186
|
|
|
* @return mixed |
187
|
|
|
*/ |
188
|
|
|
public function getFormSubmission() |
189
|
|
|
{ |
190
|
|
|
return $this->formSubmission; |
191
|
|
|
} |
192
|
|
|
|
193
|
|
|
/** |
194
|
|
|
* @param mixed $formSubmission |
195
|
|
|
*/ |
196
|
|
|
public function setFormSubmission($formSubmission) |
197
|
|
|
{ |
198
|
|
|
$this->formSubmission = $formSubmission; |
199
|
|
|
} |
200
|
|
|
|
201
|
|
|
/** |
202
|
|
|
* @return mixed |
203
|
|
|
*/ |
204
|
|
|
public function getInternalName() |
205
|
|
|
{ |
206
|
|
|
return $this->internalName; |
207
|
|
|
} |
208
|
|
|
|
209
|
|
|
/** |
210
|
|
|
* @param mixed $internalName |
211
|
|
|
*/ |
212
|
|
|
public function setInternalName($internalName) |
213
|
|
|
{ |
214
|
|
|
$this->internalName = $internalName; |
215
|
|
|
} |
216
|
|
|
|
217
|
|
|
/** |
218
|
|
|
* Text representation of this field |
219
|
|
|
* |
220
|
|
|
* @return string |
221
|
|
|
*/ |
222
|
|
|
public function __toString() |
223
|
|
|
{ |
224
|
|
|
return "FormSubmission Field"; |
225
|
|
|
} |
226
|
|
|
|
227
|
|
|
/** |
228
|
|
|
* This function will be triggered if the form was successfully posted. |
229
|
|
|
* |
230
|
|
|
* @param Form $form the Form |
231
|
|
|
* @param FormBuilderInterface $formBuilder the FormBuilder |
232
|
|
|
* @param Request $request the Request |
233
|
|
|
* @param ContainerInterface $container the Container |
234
|
|
|
*/ |
235
|
|
|
public function onValidPost(Form $form, FormBuilderInterface $formBuilder, Request $request, ContainerInterface $container) |
236
|
|
|
{ |
237
|
|
|
// do nothing by default |
238
|
|
|
} |
239
|
|
|
} |
240
|
|
|
|
This check compares the return type specified in the
@return
annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.