1 | <?php |
||
19 | class User implements UserInterface, \Serializable |
||
20 | { |
||
21 | use ORMBehaviors\Timestampable\Timestampable; |
||
22 | /** |
||
23 | * @var int |
||
24 | * |
||
25 | * @ORM\Column(type="integer") |
||
26 | * @ORM\Id |
||
27 | * @ORM\GeneratedValue(strategy="AUTO") |
||
28 | * @Groups({"Default", "Short", "Detail"}) |
||
29 | */ |
||
30 | private $id; |
||
31 | |||
32 | /** |
||
33 | * @var string |
||
34 | * @Assert\NotBlank() |
||
35 | * @Assert\Regex( |
||
36 | * pattern="/\d/", |
||
37 | * match=false, |
||
38 | * message="Your name cannot contain a number" |
||
39 | * ) |
||
40 | * @Assert\Type("string") |
||
41 | * @Assert\Length( |
||
42 | * min = 2, |
||
43 | * max = 190 |
||
44 | * ) |
||
45 | * @ORM\Column(type="string", length=190) |
||
46 | * @Groups({"Default", "Short", "Detail"}) |
||
47 | */ |
||
48 | private $firstName; |
||
49 | |||
50 | /** |
||
51 | * @var string |
||
52 | * @Assert\NotBlank() |
||
53 | * @Assert\Regex( |
||
54 | * pattern="/\d/", |
||
55 | * match=false, |
||
56 | * message="Your lastname cannot contain a number" |
||
57 | * ) |
||
58 | * @Assert\Type("string") |
||
59 | * @Assert\Length( |
||
60 | * max = 190 |
||
61 | * ) |
||
62 | * @ORM\Column(type="string", length=190, nullable=true) |
||
63 | * @Groups({"Default", "Short", "Detail"}) |
||
64 | */ |
||
65 | private $lastName; |
||
66 | |||
67 | /** |
||
68 | * @var string |
||
69 | * @ORM\OneToOne( |
||
70 | * targetEntity="AppBundle\Entity\S3\Image", |
||
71 | * cascade={"persist", "remove"}, |
||
72 | * fetch="EAGER", |
||
73 | * orphanRemoval=true |
||
74 | * ) |
||
75 | * @Groups({"Short", "Detail"}) |
||
76 | */ |
||
77 | private $image; |
||
78 | |||
79 | |||
80 | /** |
||
81 | * @var string |
||
82 | * @Assert\NotBlank() |
||
83 | * @Assert\Email( |
||
84 | * checkMX = true |
||
85 | * ) |
||
86 | * @Assert\Type("string") |
||
87 | * @Assert\Length( |
||
88 | * max = 250 |
||
89 | * ) |
||
90 | * @ORM\Column(type="string", length=250, unique=true) |
||
91 | * @Groups({"Short", "Detail"}) |
||
92 | */ |
||
93 | private $email; |
||
94 | |||
95 | /** |
||
96 | * @var string |
||
97 | * @ORM\Column(type="string", length=255) |
||
98 | */ |
||
99 | private $password; |
||
100 | |||
101 | /** |
||
102 | * @var string |
||
103 | * @Assert\Type("string") |
||
104 | * @Assert\Length( |
||
105 | * max = 255 |
||
106 | * ) |
||
107 | * @Assert\NotBlank(groups={"registration"}) |
||
108 | */ |
||
109 | private $plainPassword; |
||
110 | |||
111 | /** |
||
112 | * @var bool |
||
113 | * @ORM\Column(type="boolean") |
||
114 | */ |
||
115 | private $enabled = true; |
||
116 | |||
117 | /** |
||
118 | * @var |
||
119 | * @ORM\Column(type="json_array") |
||
120 | */ |
||
121 | protected $roles; |
||
122 | |||
123 | /** |
||
124 | * @var string |
||
125 | * |
||
126 | * @ORM\Column(type="string", unique=true, nullable=true) |
||
127 | */ |
||
128 | private $apiToken; |
||
129 | |||
130 | /** |
||
131 | * @var ArrayCollection[Event] |
||
132 | * @ORM\ManyToMany(targetEntity="Event", inversedBy="users", cascade={"persist", "remove"}) |
||
133 | * @Groups({"Detail"}) |
||
134 | */ |
||
135 | private $events; |
||
136 | |||
137 | /** |
||
138 | * @var ArrayCollection[FormRequest] |
||
139 | * @ORM\OneToMany(targetEntity="FormRequest", mappedBy="user") |
||
140 | * @Groups({"Detail"}) |
||
141 | */ |
||
142 | private $formRequests; |
||
143 | |||
144 | /** |
||
145 | * @var ArrayCollection[Survey] |
||
146 | * @ORM\OneToMany(targetEntity="Survey", mappedBy="user") |
||
147 | */ |
||
148 | private $surveys; |
||
149 | |||
150 | /** |
||
151 | * @var ArrayCollection[SurveyAnswer] |
||
152 | * @ORM\OneToMany(targetEntity="SurveyAnswer", mappedBy="user") |
||
153 | */ |
||
154 | private $answers; |
||
155 | |||
156 | 1 | public function __construct() |
|
157 | { |
||
158 | 1 | $this->events = new ArrayCollection(); |
|
159 | 1 | $this->formRequests = new ArrayCollection(); |
|
160 | 1 | $this->surveys = new ArrayCollection(); |
|
161 | 1 | $this->answers = new ArrayCollection(); |
|
162 | 1 | $this->roles = array('ROLE_USER'); |
|
163 | 1 | } |
|
164 | |||
165 | /** |
||
166 | * Get id. |
||
167 | * |
||
168 | * @return int |
||
169 | */ |
||
170 | 4 | public function getId() |
|
171 | { |
||
172 | 4 | return $this->id; |
|
173 | } |
||
174 | |||
175 | /** |
||
176 | * Get name. |
||
177 | * |
||
178 | * @return string |
||
179 | */ |
||
180 | 1 | public function getUsername() |
|
181 | { |
||
182 | 1 | return $this->email; |
|
183 | } |
||
184 | |||
185 | /** |
||
186 | * Set firstname. |
||
187 | * |
||
188 | * @param string $name |
||
189 | * |
||
190 | * @return User |
||
191 | */ |
||
192 | 2 | public function setFirstName($name) |
|
193 | { |
||
194 | 2 | $this->firstName = $name; |
|
195 | |||
196 | 2 | return $this; |
|
197 | } |
||
198 | |||
199 | /** |
||
200 | * Get first name. |
||
201 | * |
||
202 | * @return string |
||
203 | */ |
||
204 | 5 | public function getFirstName() |
|
205 | { |
||
206 | 5 | return $this->firstName; |
|
207 | } |
||
208 | |||
209 | /** |
||
210 | * Set lastName. |
||
211 | * |
||
212 | * @param string $lastName |
||
213 | * |
||
214 | * @return User |
||
215 | */ |
||
216 | 2 | public function setLastName($lastName) |
|
217 | { |
||
218 | 2 | $this->lastName = $lastName; |
|
219 | |||
220 | 2 | return $this; |
|
221 | } |
||
222 | |||
223 | /** |
||
224 | * Get lastName. |
||
225 | * |
||
226 | * @return string |
||
227 | */ |
||
228 | 5 | public function getLastName() |
|
229 | { |
||
230 | 5 | return $this->lastName; |
|
231 | } |
||
232 | |||
233 | /** |
||
234 | * Set image. |
||
235 | * |
||
236 | * @param string $image |
||
237 | * |
||
238 | * @return User |
||
239 | */ |
||
240 | public function setImage($image) |
||
241 | { |
||
242 | $this->image = $image; |
||
243 | |||
244 | return $this; |
||
245 | } |
||
246 | |||
247 | /** |
||
248 | * Get image. |
||
249 | * |
||
250 | * @return string |
||
251 | */ |
||
252 | 2 | public function getImage() |
|
253 | { |
||
254 | 2 | return $this->image; |
|
255 | } |
||
256 | |||
257 | /** |
||
258 | * Set email. |
||
259 | * |
||
260 | * @param string $email |
||
261 | * |
||
262 | * @return User |
||
263 | */ |
||
264 | 2 | public function setEmail($email) |
|
265 | { |
||
266 | 2 | $this->email = $email; |
|
267 | |||
268 | 2 | return $this; |
|
269 | } |
||
270 | |||
271 | /** |
||
272 | * Get email. |
||
273 | * |
||
274 | * @return string |
||
275 | */ |
||
276 | 5 | public function getEmail() |
|
277 | { |
||
278 | 5 | return $this->email; |
|
279 | } |
||
280 | |||
281 | /** |
||
282 | * Set password. |
||
283 | * |
||
284 | * @param string $password |
||
285 | * |
||
286 | * @return User |
||
287 | */ |
||
288 | 2 | public function setPassword($password) |
|
289 | { |
||
290 | 2 | $this->password = $password; |
|
291 | |||
292 | 2 | return $this; |
|
293 | } |
||
294 | |||
295 | /** |
||
296 | * Get password. |
||
297 | * |
||
298 | * @return string |
||
299 | */ |
||
300 | 1 | public function getPassword() |
|
301 | { |
||
302 | 1 | return $this->password; |
|
303 | } |
||
304 | |||
305 | /** |
||
306 | * @return string |
||
307 | */ |
||
308 | 4 | public function getPlainPassword() |
|
309 | { |
||
310 | 4 | return $this->plainPassword; |
|
311 | } |
||
312 | |||
313 | /** |
||
314 | * @param string $plainPassword |
||
315 | */ |
||
316 | 3 | public function setPlainPassword($plainPassword) |
|
317 | { |
||
318 | 3 | $this->plainPassword = $plainPassword; |
|
319 | 3 | } |
|
320 | |||
321 | /** |
||
322 | * @param mixed $roles |
||
323 | */ |
||
324 | public function setRoles($roles) |
||
325 | { |
||
326 | $this->roles = $roles; |
||
327 | } |
||
328 | |||
329 | /** |
||
330 | * @return mixed |
||
331 | */ |
||
332 | 1 | public function getRoles() |
|
333 | { |
||
334 | 1 | return $this->roles; |
|
335 | } |
||
336 | |||
337 | /** |
||
338 | * Set api token. |
||
339 | * |
||
340 | * @param string $apiToken |
||
341 | * |
||
342 | * @return User |
||
343 | */ |
||
344 | 1 | public function setApiToken($apiToken) |
|
345 | { |
||
346 | 1 | $this->apiToken = $apiToken; |
|
347 | |||
348 | 1 | return $this; |
|
349 | } |
||
350 | |||
351 | /** |
||
352 | * @return string |
||
353 | */ |
||
354 | public function getApiToken() |
||
355 | { |
||
356 | return $this->apiToken; |
||
357 | } |
||
358 | |||
359 | /** |
||
360 | * @param Event $event |
||
361 | * |
||
362 | * @return User |
||
363 | */ |
||
364 | public function setEvent($event) |
||
373 | |||
374 | /** |
||
375 | * @return ArrayCollection |
||
376 | */ |
||
377 | 1 | public function getEvents() |
|
378 | { |
||
379 | 1 | return $this->events; |
|
380 | } |
||
381 | |||
382 | /** |
||
383 | * @return ArrayCollection |
||
384 | */ |
||
385 | 1 | public function getFormRequests() |
|
389 | |||
390 | /** |
||
391 | * @return ArrayCollection |
||
392 | */ |
||
393 | public function getSurveys() |
||
397 | /** |
||
398 | * @return ArrayCollection |
||
399 | */ |
||
400 | public function getAnswers() |
||
404 | |||
405 | /** |
||
406 | * Set enabled |
||
407 | * |
||
408 | * @param boolean $enabled |
||
409 | * |
||
410 | * @return User |
||
411 | */ |
||
412 | 1 | public function setEnabled(bool $enabled) |
|
413 | { |
||
414 | 1 | $this->enabled = $enabled; |
|
415 | |||
416 | 1 | return $this; |
|
417 | } |
||
418 | |||
419 | /** |
||
420 | * Get enabled |
||
421 | * |
||
422 | * @return boolean |
||
423 | */ |
||
424 | 3 | public function isEnabled() |
|
425 | { |
||
426 | 3 | return $this->enabled; |
|
427 | } |
||
428 | |||
429 | 2 | public function getSalt() |
|
430 | { |
||
431 | // TODO: Implement getSalt() method. |
||
432 | 2 | } |
|
433 | |||
434 | 1 | public function eraseCredentials() |
|
435 | { |
||
436 | 1 | $this->setPlainPassword(null); |
|
437 | 1 | } |
|
438 | |||
439 | /** @see \Serializable::serialize() */ |
||
440 | public function serialize() |
||
450 | |||
451 | /** @see \Serializable::unserialize() */ |
||
452 | public function unserialize($serialized) |
||
461 | } |
||
462 |