1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace AppBundle\Entity; |
4
|
|
|
|
5
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
6
|
|
|
use Doctrine\ORM\Mapping as ORM; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* Poll. |
10
|
|
|
* |
11
|
|
|
* @ORM\Table(name="polls") |
12
|
|
|
* @ORM\Entity(repositoryClass="AppBundle\Repository\PollRepository") |
13
|
|
|
*/ |
14
|
|
|
class Poll |
15
|
|
|
{ |
16
|
|
|
/** |
17
|
|
|
* @var int |
18
|
|
|
* |
19
|
|
|
* @ORM\Column(name="id", type="integer") |
20
|
|
|
* @ORM\Id |
21
|
|
|
* @ORM\GeneratedValue(strategy="AUTO") |
22
|
|
|
*/ |
23
|
|
|
private $id; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @var string |
27
|
|
|
* |
28
|
|
|
* @ORM\Column(name="name", type="string", length=255) |
29
|
|
|
*/ |
30
|
|
|
private $name; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @var \DateTime |
34
|
|
|
* |
35
|
|
|
* @ORM\Column(name="start", type="datetime") |
36
|
|
|
*/ |
37
|
|
|
private $start; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @var \AppBundle\Entity\User |
41
|
|
|
* |
42
|
|
|
* @ORM\ManyToOne(targetEntity="User", inversedBy="createdPolls") |
43
|
|
|
* @ORM\JoinColumn(name="creator_id", referencedColumnName="id") |
44
|
|
|
*/ |
45
|
|
|
private $creator; |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @var \AppBundle\Entity\PollType |
49
|
|
|
* |
50
|
|
|
* @ORM\ManyToOne(targetEntity="PollType", inversedBy="polls") |
51
|
|
|
* @ORM\JoinColumn(name="poll_type_id", referencedColumnName="id") |
52
|
|
|
*/ |
53
|
|
|
private $pollType; |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @var string |
57
|
|
|
* |
58
|
|
|
* @ORM\Column(name="description", type="text", nullable=true) |
59
|
|
|
*/ |
60
|
|
|
private $description; |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @ORM\OneToMany(targetEntity="Vote", mappedBy="poll") |
64
|
|
|
*/ |
65
|
|
|
private $votes; |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @ORM\ManyToMany(targetEntity="AppBundle\Entity\Choice") |
69
|
|
|
*/ |
70
|
|
|
private $choices; |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* Constructor. |
74
|
|
|
*/ |
75
|
|
|
public function __construct() |
76
|
|
|
{ |
77
|
|
|
$this->votes = new ArrayCollection(); |
78
|
|
|
$this->choices = new ArrayCollection(); |
79
|
|
|
$this->start = new \DateTime(); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* Get id. |
84
|
|
|
* |
85
|
|
|
* @return int |
86
|
|
|
*/ |
87
|
|
|
public function getId(): int |
88
|
|
|
{ |
89
|
|
|
return $this->id; |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* Set name. |
94
|
|
|
* |
95
|
|
|
* @param string $name |
96
|
|
|
* |
97
|
|
|
* @return Poll |
98
|
|
|
*/ |
99
|
|
|
public function setName(string $name) |
100
|
|
|
{ |
101
|
|
|
$this->name = $name; |
102
|
|
|
|
103
|
|
|
return $this; |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
/** |
107
|
|
|
* Get name. |
108
|
|
|
* |
109
|
|
|
* @return string |
110
|
|
|
*/ |
111
|
|
|
public function getName(): string |
112
|
|
|
{ |
113
|
|
|
return $this->name; |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* Set start. |
118
|
|
|
* |
119
|
|
|
* @param \DateTime $start |
120
|
|
|
* |
121
|
|
|
* @return Poll |
122
|
|
|
*/ |
123
|
|
|
public function setStart(\DateTime $start) |
124
|
|
|
{ |
125
|
|
|
$this->start = $start; |
126
|
|
|
|
127
|
|
|
return $this; |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
/** |
131
|
|
|
* Get start. |
132
|
|
|
* |
133
|
|
|
* @return \DateTime |
134
|
|
|
*/ |
135
|
|
|
public function getStart(): DateTime |
136
|
|
|
{ |
137
|
|
|
return $this->start; |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
/** |
141
|
|
|
* Set description. |
142
|
|
|
* |
143
|
|
|
* @param string $description |
144
|
|
|
* |
145
|
|
|
* @return Poll |
146
|
|
|
*/ |
147
|
|
|
public function setDescription(string $description) |
148
|
|
|
{ |
149
|
|
|
$this->description = $description; |
150
|
|
|
|
151
|
|
|
return $this; |
152
|
|
|
} |
153
|
|
|
|
154
|
|
|
/** |
155
|
|
|
* Get description. |
156
|
|
|
* |
157
|
|
|
* @return string |
158
|
|
|
*/ |
159
|
|
|
public function getDescription(): string |
160
|
|
|
{ |
161
|
|
|
return $this->description; |
162
|
|
|
} |
163
|
|
|
|
164
|
|
|
/** |
165
|
|
|
* Set creator. |
166
|
|
|
* |
167
|
|
|
* @param \AppBundle\Entity\User $creator |
168
|
|
|
* |
169
|
|
|
* @return Poll |
170
|
|
|
*/ |
171
|
|
|
public function setCreator(\AppBundle\Entity\User $creator = null) |
172
|
|
|
{ |
173
|
|
|
$this->creator = $creator; |
174
|
|
|
|
175
|
|
|
return $this; |
176
|
|
|
} |
177
|
|
|
|
178
|
|
|
/** |
179
|
|
|
* Get creator. |
180
|
|
|
* |
181
|
|
|
* @return \AppBundle\Entity\User |
182
|
|
|
*/ |
183
|
|
|
public function getCreator(): AppBundle\Entity\User |
184
|
|
|
{ |
185
|
|
|
return $this->creator; |
186
|
|
|
} |
187
|
|
|
|
188
|
|
|
/** |
189
|
|
|
* Add vote. |
190
|
|
|
* |
191
|
|
|
* @param \AppBundle\Entity\Vote $vote |
192
|
|
|
* |
193
|
|
|
* @return Poll |
194
|
|
|
*/ |
195
|
|
|
public function addVote(\AppBundle\Entity\Vote $vote) |
196
|
|
|
{ |
197
|
|
|
$this->votes[] = $vote; |
198
|
|
|
|
199
|
|
|
return $this; |
200
|
|
|
} |
201
|
|
|
|
202
|
|
|
/** |
203
|
|
|
* Remove vote. |
204
|
|
|
* |
205
|
|
|
* @param \AppBundle\Entity\Vote $vote |
206
|
|
|
*/ |
207
|
|
|
public function removeVote(\AppBundle\Entity\Vote $vote) |
208
|
|
|
{ |
209
|
|
|
$this->votes->removeElement($vote); |
210
|
|
|
} |
211
|
|
|
|
212
|
|
|
/** |
213
|
|
|
* Get votes. |
214
|
|
|
* |
215
|
|
|
* @return \Doctrine\Common\Collections\Collection |
216
|
|
|
*/ |
217
|
|
|
public function getVotes() |
218
|
|
|
{ |
219
|
|
|
return $this->votes; |
220
|
|
|
} |
221
|
|
|
|
222
|
|
|
/** |
223
|
|
|
* Add choice. |
224
|
|
|
* |
225
|
|
|
* @param \AppBundle\Entity\Choice $choice |
226
|
|
|
* |
227
|
|
|
* @return Poll |
228
|
|
|
*/ |
229
|
|
|
public function addChoice(\AppBundle\Entity\Choice $choice) |
230
|
|
|
{ |
231
|
|
|
$this->choices[] = $choice; |
232
|
|
|
|
233
|
|
|
return $this; |
234
|
|
|
} |
235
|
|
|
|
236
|
|
|
/** |
237
|
|
|
* Remove choice. |
238
|
|
|
* |
239
|
|
|
* @param \AppBundle\Entity\Choice $choice |
240
|
|
|
*/ |
241
|
|
|
public function removeChoice(\AppBundle\Entity\Choice $choice) |
242
|
|
|
{ |
243
|
|
|
$this->choices->removeElement($choice); |
244
|
|
|
} |
245
|
|
|
|
246
|
|
|
/** |
247
|
|
|
* Get choices. |
248
|
|
|
* |
249
|
|
|
* @return \Doctrine\Common\Collections\Collection |
250
|
|
|
*/ |
251
|
|
|
public function getChoices() |
252
|
|
|
{ |
253
|
|
|
return $this->choices; |
254
|
|
|
} |
255
|
|
|
|
256
|
|
|
/** |
257
|
|
|
* Set pollType |
258
|
|
|
* |
259
|
|
|
* @param \AppBundle\Entity\PollType $pollType |
260
|
|
|
* |
261
|
|
|
* @return Poll |
262
|
|
|
*/ |
263
|
|
|
public function setPollType(\AppBundle\Entity\PollType $pollType = null) |
264
|
|
|
{ |
265
|
|
|
$this->pollType = $pollType; |
266
|
|
|
|
267
|
|
|
return $this; |
268
|
|
|
} |
269
|
|
|
|
270
|
|
|
/** |
271
|
|
|
* Get pollType |
272
|
|
|
* |
273
|
|
|
* @return \AppBundle\Entity\PollType |
274
|
|
|
*/ |
275
|
|
|
public function getPollType() |
276
|
|
|
{ |
277
|
|
|
return $this->pollType; |
278
|
|
|
} |
279
|
|
|
} |
280
|
|
|
|