1 | <?php |
||
18 | class User implements UserInterface, \Serializable |
||
19 | { |
||
20 | use ORMBehaviors\Timestampable\Timestampable; |
||
21 | /** |
||
22 | * @var int |
||
23 | * |
||
24 | * @ORM\Column(type="integer") |
||
25 | * @ORM\Id |
||
26 | * @ORM\GeneratedValue(strategy="AUTO") |
||
27 | */ |
||
28 | private $id; |
||
29 | |||
30 | /** |
||
31 | * @var string |
||
32 | * @Assert\NotBlank() |
||
33 | * @Assert\Regex( |
||
34 | * pattern="/\d/", |
||
35 | * match=false, |
||
36 | * message="Your name cannot contain a number" |
||
37 | * ) |
||
38 | * @Assert\Type("string") |
||
39 | * @Assert\Length( |
||
40 | * min = 2, |
||
41 | * max = 190 |
||
42 | * ) |
||
43 | * @ORM\Column(type="string", length=190) |
||
44 | */ |
||
45 | private $firstName; |
||
46 | |||
47 | /** |
||
48 | * @var string |
||
49 | * @Assert\NotBlank() |
||
50 | * @Assert\Regex( |
||
51 | * pattern="/\d/", |
||
52 | * match=false, |
||
53 | * message="Your lastname cannot contain a number" |
||
54 | * ) |
||
55 | * @Assert\Type("string") |
||
56 | * @Assert\Length( |
||
57 | * max = 190 |
||
58 | * ) |
||
59 | * @ORM\Column(type="string", length=190, nullable=true) |
||
60 | */ |
||
61 | private $lastName; |
||
62 | |||
63 | /** |
||
64 | * @var string |
||
65 | * @Assert\Image() |
||
66 | * @ORM\Column(type="string", nullable=true) |
||
67 | */ |
||
68 | private $image; |
||
69 | |||
70 | /** |
||
71 | * @var string |
||
72 | * @Assert\NotBlank() |
||
73 | * @Assert\Email( |
||
74 | * checkMX = true |
||
75 | * ) |
||
76 | * @Assert\Type("string") |
||
77 | * @Assert\Length( |
||
78 | * max = 250 |
||
79 | * ) |
||
80 | * @ORM\Column(type="string", length=250, unique=true) |
||
81 | */ |
||
82 | private $email; |
||
83 | |||
84 | /** |
||
85 | * @var string |
||
86 | * @ORM\Column(type="string", length=255) |
||
87 | */ |
||
88 | private $password; |
||
89 | |||
90 | /** |
||
91 | * @var string |
||
92 | * @Assert\Type("string") |
||
93 | * @Assert\Length( |
||
94 | * max = 255 |
||
95 | * ) |
||
96 | * @Assert\NotBlank(groups={"registration"}) |
||
97 | */ |
||
98 | private $plainPassword; |
||
99 | |||
100 | /** |
||
101 | * @var bool |
||
102 | * @ORM\Column(type="boolean") |
||
103 | */ |
||
104 | private $enabled = true; |
||
105 | |||
106 | /** |
||
107 | * @var |
||
108 | * @ORM\Column(type="json_array") |
||
109 | */ |
||
110 | protected $roles; |
||
111 | |||
112 | /** |
||
113 | * @var string |
||
114 | * |
||
115 | * @ORM\Column(type="string", unique=true, nullable=true) |
||
116 | */ |
||
117 | private $apiToken; |
||
118 | |||
119 | /** |
||
120 | * @var ArrayCollection[Event] |
||
121 | * @ORM\ManyToMany(targetEntity="Event", inversedBy="users") |
||
122 | */ |
||
123 | private $events; |
||
124 | |||
125 | /** |
||
126 | * @var ArrayCollection[FormRequest] |
||
127 | * @ORM\OneToMany(targetEntity="FormRequest", mappedBy="user") |
||
128 | */ |
||
129 | private $formRequests; |
||
130 | |||
131 | /** |
||
132 | * @var ArrayCollection[Survey] |
||
133 | * @ORM\OneToMany(targetEntity="Survey", mappedBy="user") |
||
134 | */ |
||
135 | private $surveys; |
||
136 | |||
137 | /** |
||
138 | * @var ArrayCollection[SurveyAnswer] |
||
139 | * @ORM\OneToMany(targetEntity="SurveyAnswer", mappedBy="user") |
||
140 | */ |
||
141 | private $answers; |
||
142 | |||
143 | public function __construct() |
||
151 | |||
152 | /** |
||
153 | * Get id. |
||
154 | * |
||
155 | * @return int |
||
156 | */ |
||
157 | public function getId() |
||
158 | { |
||
159 | return $this->id; |
||
160 | } |
||
161 | |||
162 | /** |
||
163 | * Get name. |
||
164 | * |
||
165 | * @return string |
||
166 | */ |
||
167 | public function getUsername() |
||
171 | |||
172 | /** |
||
173 | * Set firstname. |
||
174 | * |
||
175 | * @param string $name |
||
176 | * |
||
177 | * @return User |
||
178 | */ |
||
179 | public function setFirstName($name) |
||
180 | { |
||
181 | $this->firstName = $name; |
||
182 | |||
183 | return $this; |
||
184 | } |
||
185 | |||
186 | /** |
||
187 | * Get first name. |
||
188 | * |
||
189 | * @return string |
||
190 | */ |
||
191 | public function getFirstName() |
||
192 | { |
||
193 | return $this->firstName; |
||
194 | } |
||
195 | |||
196 | /** |
||
197 | * Set lastName. |
||
198 | * |
||
199 | * @param string $lastName |
||
200 | * |
||
201 | * @return User |
||
202 | */ |
||
203 | public function setLastName($lastName) |
||
204 | { |
||
205 | $this->lastName = $lastName; |
||
206 | |||
207 | return $this; |
||
208 | } |
||
209 | |||
210 | /** |
||
211 | * Get lastName. |
||
212 | * |
||
213 | * @return string |
||
214 | */ |
||
215 | public function getLastName() |
||
216 | { |
||
217 | return $this->lastName; |
||
218 | } |
||
219 | |||
220 | /** |
||
221 | * Set image. |
||
222 | * |
||
223 | * @param string $image |
||
224 | * |
||
225 | * @return User |
||
226 | */ |
||
227 | public function setImage($image) |
||
228 | { |
||
229 | $this->image = $image; |
||
230 | |||
231 | return $this; |
||
232 | } |
||
233 | |||
234 | /** |
||
235 | * Get image. |
||
236 | * |
||
237 | * @return string |
||
238 | */ |
||
239 | public function getImage() |
||
240 | { |
||
241 | return $this->image; |
||
242 | } |
||
243 | |||
244 | /** |
||
245 | * Set email. |
||
246 | * |
||
247 | * @param string $email |
||
248 | * |
||
249 | * @return User |
||
250 | */ |
||
251 | public function setEmail($email) |
||
252 | { |
||
253 | $this->email = $email; |
||
254 | |||
255 | return $this; |
||
256 | } |
||
257 | |||
258 | /** |
||
259 | * Get email. |
||
260 | * |
||
261 | * @return string |
||
262 | */ |
||
263 | public function getEmail() |
||
267 | |||
268 | /** |
||
269 | * Set password. |
||
270 | * |
||
271 | * @param string $password |
||
272 | * |
||
273 | * @return User |
||
274 | */ |
||
275 | public function setPassword($password) |
||
281 | |||
282 | /** |
||
283 | * Get password. |
||
284 | * |
||
285 | * @return string |
||
286 | */ |
||
287 | public function getPassword() |
||
291 | |||
292 | /** |
||
293 | * @return string |
||
294 | */ |
||
295 | public function getPlainPassword() |
||
296 | { |
||
297 | return $this->plainPassword; |
||
298 | } |
||
299 | |||
300 | /** |
||
301 | * @param string $plainPassword |
||
302 | */ |
||
303 | public function setPlainPassword($plainPassword) |
||
304 | { |
||
305 | $this->plainPassword = $plainPassword; |
||
306 | } |
||
307 | |||
308 | /** |
||
309 | * @param mixed $roles |
||
310 | */ |
||
311 | public function setRoles($roles) |
||
312 | { |
||
313 | $this->roles = $roles; |
||
314 | } |
||
315 | |||
316 | /** |
||
317 | * @return mixed |
||
318 | */ |
||
319 | public function getRoles() |
||
323 | |||
324 | /** |
||
325 | * Set api token. |
||
326 | * |
||
327 | * @param string $apiToken |
||
328 | * |
||
329 | * @return User |
||
330 | */ |
||
331 | public function setApiToken($apiToken) |
||
332 | { |
||
333 | $this->apiToken = $apiToken; |
||
334 | |||
335 | return $this; |
||
336 | } |
||
337 | |||
338 | /** |
||
339 | * @return string |
||
340 | */ |
||
341 | public function getApiToken() |
||
342 | { |
||
343 | return $this->apiToken; |
||
344 | } |
||
345 | |||
346 | /** |
||
347 | * @param Event $event |
||
348 | * |
||
349 | * @return User |
||
350 | */ |
||
351 | public function setEvent($event) |
||
360 | |||
361 | /** |
||
362 | * @return ArrayCollection |
||
363 | */ |
||
364 | public function getEvents() |
||
368 | |||
369 | /** |
||
370 | * @return ArrayCollection |
||
371 | */ |
||
372 | public function getFormRequests() |
||
376 | |||
377 | /** |
||
378 | * @return ArrayCollection |
||
379 | */ |
||
380 | public function getSurveys() |
||
384 | /** |
||
385 | * @return ArrayCollection |
||
386 | */ |
||
387 | public function getAnswers() |
||
391 | |||
392 | public function getSalt() |
||
396 | |||
397 | public function eraseCredentials() |
||
401 | |||
402 | /** @see \Serializable::serialize() */ |
||
403 | public function serialize() |
||
413 | |||
414 | /** @see \Serializable::unserialize() */ |
||
415 | public function unserialize($serialized) |
||
424 | |||
425 | /** |
||
426 | * Set enabled |
||
427 | * |
||
428 | * @param boolean $enabled |
||
429 | * |
||
430 | * @return User |
||
431 | */ |
||
432 | public function setEnabled(bool $enabled) |
||
433 | { |
||
434 | $this->enabled = $enabled; |
||
435 | |||
436 | return $this; |
||
437 | } |
||
438 | |||
439 | /** |
||
440 | * Get enabled |
||
441 | * |
||
442 | * @return boolean |
||
443 | */ |
||
444 | public function isEnabled() |
||
448 | |||
449 | /** |
||
450 | * Add event |
||
451 | * |
||
452 | * @param \AppBundle\Entity\Event $event |
||
453 | * |
||
454 | * @return User |
||
455 | */ |
||
456 | public function addEvent(\AppBundle\Entity\Event $event) |
||
462 | |||
463 | /** |
||
464 | * Remove event |
||
465 | * |
||
466 | * @param \AppBundle\Entity\Event $event |
||
467 | */ |
||
468 | public function removeEvent(\AppBundle\Entity\Event $event) |
||
472 | |||
473 | /** |
||
474 | * Add formRequest |
||
475 | * |
||
476 | * @param \AppBundle\Entity\FormRequest $formRequest |
||
477 | * |
||
478 | * @return User |
||
479 | */ |
||
480 | public function addFormRequest(\AppBundle\Entity\FormRequest $formRequest) |
||
486 | |||
487 | /** |
||
488 | * Remove formRequest |
||
489 | * |
||
490 | * @param \AppBundle\Entity\FormRequest $formRequest |
||
491 | */ |
||
492 | public function removeFormRequest(\AppBundle\Entity\FormRequest $formRequest) |
||
496 | |||
497 | /** |
||
498 | * Add survey |
||
499 | * |
||
500 | * @param \AppBundle\Entity\Survey $survey |
||
501 | * |
||
502 | * @return User |
||
503 | */ |
||
504 | public function addSurvey(\AppBundle\Entity\Survey $survey) |
||
510 | |||
511 | /** |
||
512 | * Remove survey |
||
513 | * |
||
514 | * @param \AppBundle\Entity\Survey $survey |
||
515 | */ |
||
516 | public function removeSurvey(\AppBundle\Entity\Survey $survey) |
||
520 | |||
521 | /** |
||
522 | * Add answer |
||
523 | * |
||
524 | * @param \AppBundle\Entity\SurveyAnswer $answer |
||
525 | * |
||
526 | * @return User |
||
527 | */ |
||
528 | public function addAnswer(\AppBundle\Entity\SurveyAnswer $answer) |
||
534 | |||
535 | /** |
||
536 | * Remove answer |
||
537 | * |
||
538 | * @param \AppBundle\Entity\SurveyAnswer $answer |
||
539 | */ |
||
540 | public function removeAnswer(\AppBundle\Entity\SurveyAnswer $answer) |
||
544 | } |
||
545 |