1 | <?php |
||
20 | class User implements UserInterface, \Serializable |
||
21 | { |
||
22 | use ORMBehaviors\Timestampable\Timestampable; |
||
23 | /** |
||
24 | * @var int |
||
25 | * |
||
26 | * @ORM\Column(type="integer") |
||
27 | * @ORM\Id |
||
28 | * @ORM\GeneratedValue(strategy="AUTO") |
||
29 | * @Groups({"Default", "Short", "Detail"}) |
||
30 | */ |
||
31 | private $id; |
||
32 | |||
33 | /** |
||
34 | * @var string |
||
35 | * @Assert\NotBlank(groups={"registration", "edit"}) |
||
36 | * @Assert\Regex( |
||
37 | * pattern="/\d/", |
||
38 | * match=false, |
||
39 | * message="Your name cannot contain a number", |
||
40 | * groups={"registration", "edit"} |
||
41 | * ) |
||
42 | * @Assert\Type("string") |
||
43 | * @Assert\Length( |
||
44 | * min = 2, |
||
45 | * max = 190, |
||
46 | * groups={"registration", "edit"} |
||
47 | * ) |
||
48 | * @ORM\Column(type="string", length=190) |
||
49 | * @Groups({"Default", "Short", "Detail"}) |
||
50 | */ |
||
51 | private $firstName; |
||
52 | |||
53 | /** |
||
54 | * @var string |
||
55 | * @Assert\NotBlank(groups={"registration", "edit"}) |
||
56 | * @Assert\Regex( |
||
57 | * pattern="/\d/", |
||
58 | * match=false, |
||
59 | * message="Your lastname cannot contain a number", |
||
60 | * groups={"registration", "edit"} |
||
61 | * ) |
||
62 | * @Assert\Type("string", groups={"registration", "edit"}) |
||
63 | * @Assert\Length( |
||
64 | * max = 190, |
||
65 | * groups={"registration", "edit"} |
||
66 | * ) |
||
67 | * @ORM\Column(type="string", length=190, nullable=true) |
||
68 | * @Groups({"Default", "Short", "Detail"}) |
||
69 | */ |
||
70 | private $lastName; |
||
71 | |||
72 | /** |
||
73 | * @var string |
||
74 | * @ORM\OneToOne( |
||
75 | * targetEntity="AppBundle\Entity\S3\Image", |
||
76 | * cascade={"persist", "remove"}, |
||
77 | * fetch="EAGER", |
||
78 | * orphanRemoval=true |
||
79 | * ) |
||
80 | * @Groups({"Short", "Detail"}) |
||
81 | */ |
||
82 | private $image; |
||
83 | |||
84 | /** |
||
85 | * @var string |
||
86 | * @Assert\NotBlank(groups={"registration", "edit"}) |
||
87 | * @Assert\Email( |
||
88 | * groups={"registration", "edit"} |
||
89 | * ) |
||
90 | * @Assert\Type("string", groups={"registration", "edit"}) |
||
91 | * @Assert\Length( |
||
92 | * max = 250, |
||
93 | * groups={"registration", "edit"} |
||
94 | * ) |
||
95 | * @ORM\Column(type="string", length=250, unique=true) |
||
96 | * @Groups({"Short", "Detail"}) |
||
97 | */ |
||
98 | private $email; |
||
99 | |||
100 | /** |
||
101 | * @var string |
||
102 | * @ORM\Column(type="string", length=255) |
||
103 | */ |
||
104 | private $password; |
||
105 | |||
106 | /** |
||
107 | * @var string |
||
108 | * @Assert\Type("string", groups={"registration", "edit"}) |
||
109 | * @Assert\Length( |
||
110 | * max = 255, |
||
111 | * groups={"registration", "edit"} |
||
112 | * ) |
||
113 | * @Assert\NotBlank(groups={"registration"}) |
||
114 | */ |
||
115 | private $plainPassword; |
||
116 | |||
117 | /** |
||
118 | * @var bool |
||
119 | * @ORM\Column(type="boolean") |
||
120 | */ |
||
121 | private $enabled = true; |
||
122 | |||
123 | /** |
||
124 | * @var |
||
125 | * @ORM\Column(type="json_array") |
||
126 | */ |
||
127 | protected $roles; |
||
128 | |||
129 | /** |
||
130 | * @var string |
||
131 | * |
||
132 | * @ORM\Column(type="string", unique=true, nullable=true) |
||
133 | */ |
||
134 | private $apiToken; |
||
135 | |||
136 | /** |
||
137 | * @var \DateTime |
||
138 | * @Assert\Date() |
||
139 | * @ORM\Column(type="datetime", nullable=true) |
||
140 | */ |
||
141 | private $linkExpiredAt; |
||
142 | |||
143 | /** |
||
144 | * @var ArrayCollection[Event] |
||
145 | * @ORM\ManyToMany(targetEntity="Event", mappedBy="user", cascade={"persist", "remove"}) |
||
146 | * @Groups({"Detail"}) |
||
147 | */ |
||
148 | private $events; |
||
149 | |||
150 | /** |
||
151 | * @var ArrayCollection[FormRequest] |
||
152 | * @ORM\OneToMany(targetEntity="FormRequest", mappedBy="user") |
||
153 | * @Groups({"Detail"}) |
||
154 | */ |
||
155 | private $formRequests; |
||
156 | |||
157 | /** |
||
158 | * @var ArrayCollection|$surveys[] |
||
159 | * @ORM\OneToMany(targetEntity="AppBundle\Entity\Survey\Survey", mappedBy="user") |
||
160 | */ |
||
161 | private $surveys; |
||
162 | |||
163 | 1 | public function __construct() |
|
170 | |||
171 | /** |
||
172 | * Get id. |
||
173 | * |
||
174 | * @return int |
||
175 | */ |
||
176 | 4 | public function getId() |
|
177 | { |
||
178 | 4 | return $this->id; |
|
179 | } |
||
180 | |||
181 | /** |
||
182 | * Get name. |
||
183 | * |
||
184 | * @return string |
||
185 | */ |
||
186 | 4 | public function getUsername() |
|
190 | |||
191 | /** |
||
192 | * Set firstname. |
||
193 | * |
||
194 | * @param string $name |
||
195 | * |
||
196 | * @return User |
||
197 | */ |
||
198 | 2 | public function setFirstName($name) |
|
199 | { |
||
200 | 2 | $this->firstName = $name; |
|
201 | |||
202 | 2 | return $this; |
|
203 | } |
||
204 | |||
205 | /** |
||
206 | * Get first name. |
||
207 | * |
||
208 | * @return string |
||
209 | */ |
||
210 | 9 | public function getFirstName() |
|
211 | { |
||
212 | 9 | return $this->firstName; |
|
213 | } |
||
214 | |||
215 | /** |
||
216 | * Set lastName. |
||
217 | * |
||
218 | * @param string $lastName |
||
219 | * |
||
220 | * @return User |
||
221 | */ |
||
222 | 2 | public function setLastName($lastName) |
|
223 | { |
||
224 | 2 | $this->lastName = $lastName; |
|
225 | |||
226 | 2 | return $this; |
|
227 | } |
||
228 | |||
229 | /** |
||
230 | * Get lastName. |
||
231 | * |
||
232 | * @return string |
||
233 | */ |
||
234 | 7 | public function getLastName() |
|
235 | { |
||
236 | 7 | return $this->lastName; |
|
237 | } |
||
238 | |||
239 | /** |
||
240 | * Set image. |
||
241 | * |
||
242 | * @param string $image |
||
243 | * |
||
244 | * @return User |
||
245 | */ |
||
246 | public function setImage($image) |
||
247 | { |
||
248 | $this->image = $image; |
||
249 | |||
250 | return $this; |
||
251 | } |
||
252 | |||
253 | /** |
||
254 | * Get image. |
||
255 | * |
||
256 | * @return string |
||
257 | */ |
||
258 | 2 | public function getImage() |
|
259 | { |
||
260 | 2 | return $this->image; |
|
261 | } |
||
262 | |||
263 | /** |
||
264 | * Set email. |
||
265 | * |
||
266 | * @param string $email |
||
267 | * |
||
268 | * @return User |
||
269 | */ |
||
270 | 2 | public function setEmail($email) |
|
271 | { |
||
272 | 2 | $this->email = $email; |
|
273 | |||
274 | 2 | return $this; |
|
275 | } |
||
276 | |||
277 | /** |
||
278 | * Get email. |
||
279 | * |
||
280 | * @return string |
||
281 | */ |
||
282 | 6 | public function getEmail() |
|
286 | |||
287 | /** |
||
288 | * Set password. |
||
289 | * |
||
290 | * @param string $password |
||
291 | * |
||
292 | * @return User |
||
293 | */ |
||
294 | 3 | public function setPassword($password) |
|
300 | |||
301 | /** |
||
302 | * Get password. |
||
303 | * |
||
304 | * @return string |
||
305 | */ |
||
306 | 1 | public function getPassword() |
|
310 | |||
311 | /** |
||
312 | * @return string |
||
313 | */ |
||
314 | 6 | public function getPlainPassword() |
|
315 | { |
||
316 | 6 | return $this->plainPassword; |
|
317 | } |
||
318 | |||
319 | /** |
||
320 | * @param string $plainPassword |
||
321 | */ |
||
322 | 7 | public function setPlainPassword($plainPassword) |
|
323 | { |
||
324 | 7 | $this->plainPassword = $plainPassword; |
|
325 | 7 | } |
|
326 | |||
327 | /** |
||
328 | * @param mixed $roles |
||
329 | */ |
||
330 | public function setRoles($roles) |
||
331 | { |
||
332 | $this->roles = $roles; |
||
333 | } |
||
334 | |||
335 | /** |
||
336 | * @return mixed |
||
337 | */ |
||
338 | 4 | public function getRoles() |
|
342 | |||
343 | /** |
||
344 | * Set api token. |
||
345 | * |
||
346 | * @param string $apiToken |
||
347 | * |
||
348 | * @return User |
||
349 | */ |
||
350 | 1 | public function setApiToken($apiToken) |
|
351 | { |
||
352 | 1 | $this->apiToken = $apiToken; |
|
353 | |||
354 | 1 | return $this; |
|
355 | } |
||
356 | |||
357 | /** |
||
358 | * @return string |
||
359 | */ |
||
360 | 1 | public function getApiToken() |
|
361 | { |
||
362 | 1 | return $this->apiToken; |
|
363 | } |
||
364 | |||
365 | /** |
||
366 | * Set link expired date. |
||
367 | * |
||
368 | * @param \DateTime $linkExpiredAt |
||
369 | * |
||
370 | * @return User |
||
371 | */ |
||
372 | 1 | public function setLinkExpiredAt($linkExpiredAt) |
|
378 | |||
379 | /** |
||
380 | * @return \DateTime |
||
381 | */ |
||
382 | 1 | public function getLinkExpiredAt() |
|
386 | |||
387 | /** |
||
388 | * @param Event $event |
||
389 | * |
||
390 | * @return User |
||
391 | */ |
||
392 | public function setEvent($event) |
||
401 | |||
402 | /** |
||
403 | * @return ArrayCollection |
||
404 | */ |
||
405 | 1 | public function getEvents() |
|
409 | |||
410 | /** |
||
411 | * @return ArrayCollection |
||
412 | */ |
||
413 | 1 | public function getFormRequests() |
|
417 | |||
418 | /** |
||
419 | * Set enabled. |
||
420 | * |
||
421 | * @param bool $enabled |
||
422 | * |
||
423 | * @return User |
||
424 | */ |
||
425 | 1 | public function setEnabled(bool $enabled) |
|
426 | { |
||
427 | 1 | $this->enabled = $enabled; |
|
428 | |||
429 | 1 | return $this; |
|
430 | } |
||
431 | |||
432 | /** |
||
433 | * Get enabled. |
||
434 | * |
||
435 | * @return bool |
||
436 | */ |
||
437 | 4 | public function isEnabled() |
|
441 | |||
442 | 3 | public function getSalt() |
|
446 | |||
447 | 4 | public function eraseCredentials() |
|
451 | |||
452 | /** @see \Serializable::serialize() */ |
||
453 | public function serialize() |
||
463 | |||
464 | /** @see \Serializable::unserialize() */ |
||
465 | public function unserialize($serialized) |
||
474 | |||
475 | /** |
||
476 | * Add event |
||
477 | * |
||
478 | * @param Event $event |
||
479 | * |
||
480 | * @return User |
||
481 | */ |
||
482 | public function addEvent(Event $event) |
||
488 | |||
489 | /** |
||
490 | * Remove event. |
||
491 | * |
||
492 | * @param Event $event |
||
493 | */ |
||
494 | public function removeEvent(Event $event) |
||
498 | |||
499 | /** |
||
500 | * Add formRequest. |
||
501 | * |
||
502 | * @param FormRequest $formRequest |
||
503 | * |
||
504 | * @return User |
||
505 | */ |
||
506 | public function addFormRequest(FormRequest $formRequest) |
||
512 | |||
513 | /** |
||
514 | * Remove formRequest. |
||
515 | * |
||
516 | * @param FormRequest $formRequest |
||
517 | */ |
||
518 | public function removeFormRequest(FormRequest $formRequest) |
||
522 | |||
523 | /** |
||
524 | * Add survey. |
||
525 | * |
||
526 | * @param Survey $survey |
||
527 | * |
||
528 | * @return User |
||
529 | */ |
||
530 | public function addSurvey(Survey $survey) |
||
536 | |||
537 | /** |
||
538 | * Get surveys. |
||
539 | * |
||
540 | * @return ArrayCollection |
||
541 | */ |
||
542 | public function getSurveys() |
||
546 | } |
||
547 |