|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace AppBundle\Entity\Survey; |
|
4
|
|
|
|
|
5
|
|
|
use Doctrine\ORM\Mapping as ORM; |
|
6
|
|
|
use Symfony\Component\Validator\Constraints as Assert; |
|
7
|
|
|
use Symfony\Component\Serializer\Annotation\Groups; |
|
8
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* SurveyQuestion. |
|
12
|
|
|
* |
|
13
|
|
|
* @ORM\Entity(repositoryClass="AppBundle\Repository\SurveyQuestionRepository") |
|
14
|
|
|
*/ |
|
15
|
|
|
class SurveyQuestion |
|
16
|
|
|
{ |
|
17
|
|
|
/** |
|
18
|
|
|
* @var int |
|
19
|
|
|
* |
|
20
|
|
|
* @ORM\Column(type="integer") |
|
21
|
|
|
* @ORM\Id |
|
22
|
|
|
* @ORM\GeneratedValue(strategy="AUTO") |
|
23
|
|
|
* @Groups({"group2", "group3", "group4"}) |
|
24
|
|
|
*/ |
|
25
|
|
|
private $id; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* @var string |
|
29
|
|
|
* @Assert\NotBlank() |
|
30
|
|
|
* @Assert\Type("string") |
|
31
|
|
|
* @Assert\Length( |
|
32
|
|
|
* max = 500 |
|
33
|
|
|
* ) |
|
34
|
|
|
* @ORM\Column(type="string") |
|
35
|
|
|
* @Groups({"group2"}) |
|
36
|
|
|
*/ |
|
37
|
|
|
private $title; |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* @var SurveyTypeSection |
|
41
|
|
|
* @Assert\Type("object") |
|
42
|
|
|
* @Assert\Valid |
|
43
|
|
|
* @ORM\ManyToOne(targetEntity="SurveyTypeSection", inversedBy="questions") |
|
44
|
|
|
* @ORM\JoinColumn(onDelete="SET NULL") |
|
45
|
|
|
*/ |
|
46
|
|
|
private $surveyTypeSection; |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* @var int |
|
50
|
|
|
* @Assert\NotBlank() |
|
51
|
|
|
* @Assert\Type("integer") |
|
52
|
|
|
* @ORM\Column(type="integer") |
|
53
|
|
|
* @Groups({"group2"}) |
|
54
|
|
|
*/ |
|
55
|
|
|
private $orderNumber; |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* @var array |
|
59
|
|
|
* @Assert\NotBlank() |
|
60
|
|
|
* @Assert\Type("array") |
|
61
|
|
|
* @ORM\Column(type="array") |
|
62
|
|
|
* @Groups({"group2"}) |
|
63
|
|
|
*/ |
|
64
|
|
|
private $variants; |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* @var ArrayCollection[SurveyAnswer] |
|
68
|
|
|
* @ORM\OneToMany(targetEntity="SurveyAnswer", mappedBy="question", cascade={"persist", "remove"}) |
|
69
|
|
|
*/ |
|
70
|
|
|
private $answers; |
|
71
|
|
|
|
|
72
|
|
|
public function __construct() |
|
73
|
|
|
{ |
|
74
|
|
|
$this->answers = new ArrayCollection(); |
|
75
|
|
|
$this->variants = array(); |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
/** |
|
79
|
|
|
* Get id. |
|
80
|
|
|
* |
|
81
|
|
|
* @return int |
|
82
|
|
|
*/ |
|
83
|
3 |
|
public function getId() |
|
84
|
|
|
{ |
|
85
|
3 |
|
return $this->id; |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
/** |
|
89
|
|
|
* Set title. |
|
90
|
|
|
* |
|
91
|
|
|
* @param string $title |
|
92
|
|
|
* |
|
93
|
|
|
* @return SurveyQuestion |
|
94
|
|
|
*/ |
|
95
|
|
|
public function setTitle($title) |
|
96
|
|
|
{ |
|
97
|
|
|
$this->title = $title; |
|
98
|
|
|
|
|
99
|
|
|
return $this; |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
/** |
|
103
|
|
|
* Get title. |
|
104
|
|
|
* |
|
105
|
|
|
* @return string |
|
106
|
|
|
*/ |
|
107
|
3 |
|
public function getTitle() |
|
108
|
|
|
{ |
|
109
|
3 |
|
return $this->title; |
|
110
|
|
|
} |
|
111
|
|
|
|
|
112
|
|
|
/** |
|
113
|
|
|
* Set Survey Type Section. |
|
114
|
|
|
* |
|
115
|
|
|
* @param SurveyTypeSection $section |
|
116
|
|
|
* |
|
117
|
|
|
* @return SurveyQuestion |
|
118
|
|
|
*/ |
|
119
|
|
|
public function setSurveyTypeSection(SurveyTypeSection $section) |
|
120
|
|
|
{ |
|
121
|
|
|
$this->surveyTypeSection = $section; |
|
122
|
|
|
|
|
123
|
|
|
return $this; |
|
124
|
|
|
} |
|
125
|
|
|
|
|
126
|
|
|
/** |
|
127
|
|
|
* Get Survey Type. |
|
128
|
|
|
* |
|
129
|
|
|
* @return SurveyTypeSection |
|
130
|
|
|
*/ |
|
131
|
|
|
public function getSurveyTypeSection() |
|
132
|
|
|
{ |
|
133
|
|
|
return $this->surveyTypeSection; |
|
134
|
|
|
} |
|
135
|
|
|
|
|
136
|
|
|
/** |
|
137
|
|
|
* Set order number. |
|
138
|
|
|
* |
|
139
|
|
|
* @param int $number |
|
140
|
|
|
* |
|
141
|
|
|
* @return SurveyQuestion |
|
142
|
|
|
*/ |
|
143
|
|
|
public function setOrderNumber($number) |
|
144
|
|
|
{ |
|
145
|
|
|
$this->orderNumber = $number; |
|
146
|
|
|
|
|
147
|
|
|
return $this; |
|
148
|
|
|
} |
|
149
|
|
|
|
|
150
|
|
|
/** |
|
151
|
|
|
* Get order number. |
|
152
|
|
|
* |
|
153
|
|
|
* @return int |
|
154
|
|
|
*/ |
|
155
|
|
|
public function getOrderNumber() |
|
156
|
|
|
{ |
|
157
|
|
|
return $this->orderNumber; |
|
158
|
|
|
} |
|
159
|
|
|
|
|
160
|
|
|
/** |
|
161
|
|
|
* Set variants. |
|
162
|
|
|
* |
|
163
|
|
|
* @param array $variants |
|
164
|
|
|
* |
|
165
|
|
|
* @return SurveyQuestion |
|
166
|
|
|
*/ |
|
167
|
|
|
public function setVariants($variants) |
|
168
|
|
|
{ |
|
169
|
|
|
$this->variants = $variants; |
|
170
|
|
|
|
|
171
|
|
|
return $this; |
|
172
|
|
|
} |
|
173
|
|
|
|
|
174
|
|
|
/** |
|
175
|
|
|
* Add variant. |
|
176
|
|
|
* |
|
177
|
|
|
* @param string $variant |
|
178
|
|
|
* |
|
179
|
|
|
* @return SurveyQuestion |
|
180
|
|
|
*/ |
|
181
|
|
|
public function addVariant($variant) |
|
182
|
|
|
{ |
|
183
|
|
|
if (!in_array($variant, $this->variants)) { |
|
184
|
|
|
$this->variants[] = $variant; |
|
185
|
|
|
} |
|
186
|
|
|
|
|
187
|
|
|
return $this; |
|
188
|
|
|
} |
|
189
|
|
|
|
|
190
|
|
|
/** |
|
191
|
|
|
* Get variants. |
|
192
|
|
|
* |
|
193
|
|
|
* @return array |
|
194
|
|
|
*/ |
|
195
|
4 |
|
public function getVariants() |
|
196
|
|
|
{ |
|
197
|
4 |
|
return $this->variants; |
|
198
|
|
|
} |
|
199
|
|
|
|
|
200
|
|
|
/** |
|
201
|
|
|
* Get answers. |
|
202
|
|
|
* |
|
203
|
|
|
* @return ArrayCollection |
|
204
|
|
|
*/ |
|
205
|
|
|
public function getAnswers() |
|
206
|
|
|
{ |
|
207
|
|
|
return $this->answers; |
|
208
|
|
|
} |
|
209
|
|
|
|
|
210
|
|
|
/** |
|
211
|
|
|
* Add answer |
|
212
|
|
|
* |
|
213
|
|
|
* @param \AppBundle\Entity\Survey\SurveyAnswer $answer |
|
214
|
|
|
* |
|
215
|
|
|
* @return SurveyQuestion |
|
216
|
|
|
*/ |
|
217
|
|
|
public function addAnswer(\AppBundle\Entity\Survey\SurveyAnswer $answer) |
|
218
|
|
|
{ |
|
219
|
|
|
$this->answers[] = $answer; |
|
220
|
|
|
|
|
221
|
|
|
return $this; |
|
222
|
|
|
} |
|
223
|
|
|
|
|
224
|
|
|
/** |
|
225
|
|
|
* Remove answer |
|
226
|
|
|
* |
|
227
|
|
|
* @param \AppBundle\Entity\Survey\SurveyAnswer $answer |
|
228
|
|
|
*/ |
|
229
|
|
|
public function removeAnswer(\AppBundle\Entity\Survey\SurveyAnswer $answer) |
|
230
|
|
|
{ |
|
231
|
|
|
$this->answers->removeElement($answer); |
|
232
|
|
|
} |
|
233
|
|
|
} |
|
234
|
|
|
|