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 | * @Assert\Image() |
||
70 | * @ORM\Column(type="string", nullable=true) |
||
71 | * @Groups({"Detail"}) |
||
72 | */ |
||
73 | private $image; |
||
74 | |||
75 | /** |
||
76 | * @var string |
||
77 | * @Assert\NotBlank() |
||
78 | * @Assert\Email( |
||
79 | * checkMX = true |
||
80 | * ) |
||
81 | * @Assert\Type("string") |
||
82 | * @Assert\Length( |
||
83 | * max = 250 |
||
84 | * ) |
||
85 | * @ORM\Column(type="string", length=250, unique=true) |
||
86 | * @Groups({"Short", "Detail"}) |
||
87 | */ |
||
88 | private $email; |
||
89 | |||
90 | /** |
||
91 | * @var string |
||
92 | * @ORM\Column(type="string", length=255) |
||
93 | */ |
||
94 | private $password; |
||
95 | |||
96 | /** |
||
97 | * @var string |
||
98 | * @Assert\Type("string") |
||
99 | * @Assert\Length( |
||
100 | * max = 255 |
||
101 | * ) |
||
102 | * @Assert\NotBlank(groups={"registration"}) |
||
103 | */ |
||
104 | private $plainPassword; |
||
105 | |||
106 | /** |
||
107 | * @var bool |
||
108 | * @ORM\Column(type="boolean") |
||
109 | * @Groups({"Short", "Detail"}) |
||
110 | */ |
||
111 | private $enabled = true; |
||
112 | |||
113 | /** |
||
114 | * @var |
||
115 | * @ORM\Column(type="json_array") |
||
116 | */ |
||
117 | protected $roles; |
||
118 | |||
119 | /** |
||
120 | * @var string |
||
121 | * |
||
122 | * @ORM\Column(type="string", unique=true, nullable=true) |
||
123 | */ |
||
124 | private $apiToken; |
||
125 | |||
126 | /** |
||
127 | * @var ArrayCollection[Event] |
||
128 | * @ORM\ManyToMany(targetEntity="Event", inversedBy="users", cascade={"persist", "remove"}) |
||
129 | */ |
||
130 | private $events; |
||
131 | |||
132 | /** |
||
133 | * @var ArrayCollection[FormRequest] |
||
134 | * @ORM\OneToMany(targetEntity="FormRequest", mappedBy="user") |
||
135 | */ |
||
136 | private $formRequests; |
||
137 | |||
138 | /** |
||
139 | * @var ArrayCollection[Survey] |
||
140 | * @ORM\OneToMany(targetEntity="Survey", mappedBy="user") |
||
141 | */ |
||
142 | private $surveys; |
||
143 | |||
144 | /** |
||
145 | * @var ArrayCollection[SurveyAnswer] |
||
146 | * @ORM\OneToMany(targetEntity="SurveyAnswer", mappedBy="user") |
||
147 | */ |
||
148 | private $answers; |
||
149 | |||
150 | 1 | public function __construct() |
|
158 | |||
159 | /** |
||
160 | * Get id. |
||
161 | * |
||
162 | * @return int |
||
163 | */ |
||
164 | 4 | public function getId() |
|
165 | { |
||
166 | 4 | return $this->id; |
|
167 | } |
||
168 | |||
169 | /** |
||
170 | * Get name. |
||
171 | * |
||
172 | * @return string |
||
173 | */ |
||
174 | 1 | public function getUsername() |
|
178 | |||
179 | /** |
||
180 | * Set firstname. |
||
181 | * |
||
182 | * @param string $name |
||
183 | * |
||
184 | * @return User |
||
185 | */ |
||
186 | 2 | public function setFirstName($name) |
|
187 | { |
||
188 | 2 | $this->firstName = $name; |
|
189 | |||
190 | 2 | return $this; |
|
191 | } |
||
192 | |||
193 | /** |
||
194 | * Get first name. |
||
195 | * |
||
196 | * @return string |
||
197 | */ |
||
198 | 5 | public function getFirstName() |
|
199 | { |
||
200 | 5 | return $this->firstName; |
|
201 | } |
||
202 | |||
203 | /** |
||
204 | * Set lastName. |
||
205 | * |
||
206 | * @param string $lastName |
||
207 | * |
||
208 | * @return User |
||
209 | */ |
||
210 | 2 | public function setLastName($lastName) |
|
211 | { |
||
212 | 2 | $this->lastName = $lastName; |
|
213 | |||
214 | 2 | return $this; |
|
215 | } |
||
216 | |||
217 | /** |
||
218 | * Get lastName. |
||
219 | * |
||
220 | * @return string |
||
221 | */ |
||
222 | 5 | public function getLastName() |
|
223 | { |
||
224 | 5 | return $this->lastName; |
|
225 | } |
||
226 | |||
227 | /** |
||
228 | * Set image. |
||
229 | * |
||
230 | * @param string $image |
||
231 | * |
||
232 | * @return User |
||
233 | */ |
||
234 | public function setImage($image) |
||
235 | { |
||
236 | $this->image = $image; |
||
237 | |||
238 | return $this; |
||
239 | } |
||
240 | |||
241 | /** |
||
242 | * Get image. |
||
243 | * |
||
244 | * @return string |
||
245 | */ |
||
246 | 2 | public function getImage() |
|
247 | { |
||
248 | 2 | return $this->image; |
|
249 | } |
||
250 | |||
251 | /** |
||
252 | * Set email. |
||
253 | * |
||
254 | * @param string $email |
||
255 | * |
||
256 | * @return User |
||
257 | */ |
||
258 | 2 | public function setEmail($email) |
|
259 | { |
||
260 | 2 | $this->email = $email; |
|
261 | |||
262 | 2 | return $this; |
|
263 | } |
||
264 | |||
265 | /** |
||
266 | * Get email. |
||
267 | * |
||
268 | * @return string |
||
269 | */ |
||
270 | 5 | public function getEmail() |
|
274 | |||
275 | /** |
||
276 | * Set password. |
||
277 | * |
||
278 | * @param string $password |
||
279 | * |
||
280 | * @return User |
||
281 | */ |
||
282 | 2 | public function setPassword($password) |
|
288 | |||
289 | /** |
||
290 | * Get password. |
||
291 | * |
||
292 | * @return string |
||
293 | */ |
||
294 | 1 | public function getPassword() |
|
298 | |||
299 | /** |
||
300 | * @return string |
||
301 | */ |
||
302 | 4 | public function getPlainPassword() |
|
303 | { |
||
304 | 4 | return $this->plainPassword; |
|
305 | } |
||
306 | |||
307 | /** |
||
308 | * @param string $plainPassword |
||
309 | */ |
||
310 | 3 | public function setPlainPassword($plainPassword) |
|
311 | { |
||
312 | 3 | $this->plainPassword = $plainPassword; |
|
313 | 3 | } |
|
314 | |||
315 | /** |
||
316 | * @param mixed $roles |
||
317 | */ |
||
318 | public function setRoles($roles) |
||
319 | { |
||
320 | $this->roles = $roles; |
||
321 | } |
||
322 | |||
323 | /** |
||
324 | * @return mixed |
||
325 | */ |
||
326 | 1 | public function getRoles() |
|
330 | |||
331 | /** |
||
332 | * Set api token. |
||
333 | * |
||
334 | * @param string $apiToken |
||
335 | * |
||
336 | * @return User |
||
337 | */ |
||
338 | 1 | public function setApiToken($apiToken) |
|
339 | { |
||
340 | 1 | $this->apiToken = $apiToken; |
|
341 | |||
342 | 1 | return $this; |
|
343 | } |
||
344 | |||
345 | /** |
||
346 | * @return string |
||
347 | */ |
||
348 | public function getApiToken() |
||
349 | { |
||
350 | return $this->apiToken; |
||
351 | } |
||
352 | |||
353 | /** |
||
354 | * @param Event $event |
||
355 | * |
||
356 | * @return User |
||
357 | */ |
||
358 | public function setEvent($event) |
||
367 | |||
368 | /** |
||
369 | * @return ArrayCollection |
||
370 | */ |
||
371 | public function getEvents() |
||
375 | |||
376 | /** |
||
377 | * @return ArrayCollection |
||
378 | */ |
||
379 | public function getFormRequests() |
||
383 | |||
384 | /** |
||
385 | * @return ArrayCollection |
||
386 | */ |
||
387 | public function getSurveys() |
||
391 | /** |
||
392 | * @return ArrayCollection |
||
393 | */ |
||
394 | public function getAnswers() |
||
398 | |||
399 | /** |
||
400 | * Set enabled |
||
401 | * |
||
402 | * @param boolean $enabled |
||
403 | * |
||
404 | * @return User |
||
405 | */ |
||
406 | 1 | public function setEnabled(bool $enabled) |
|
407 | { |
||
408 | 1 | $this->enabled = $enabled; |
|
409 | |||
410 | 1 | return $this; |
|
411 | } |
||
412 | |||
413 | /** |
||
414 | * Get enabled |
||
415 | * |
||
416 | * @return boolean |
||
417 | */ |
||
418 | 4 | public function isEnabled() |
|
422 | |||
423 | 2 | public function getSalt() |
|
427 | |||
428 | 1 | public function eraseCredentials() |
|
432 | |||
433 | /** @see \Serializable::serialize() */ |
||
434 | public function serialize() |
||
444 | |||
445 | /** @see \Serializable::unserialize() */ |
||
446 | public function unserialize($serialized) |
||
455 | } |
||
456 |