1 | <?php |
||
18 | class User implements AdvancedUserInterface, \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 | * @ORM\Column(type="boolean") |
||
102 | */ |
||
103 | private $isActive = true; |
||
104 | |||
105 | /** |
||
106 | * @var |
||
107 | * @ORM\Column(type="json_array") |
||
108 | */ |
||
109 | protected $roles; |
||
110 | |||
111 | /** |
||
112 | * @var string |
||
113 | * |
||
114 | * @ORM\Column(type="string", unique=true, nullable=true) |
||
115 | */ |
||
116 | private $apiToken; |
||
117 | |||
118 | /** |
||
119 | * @var ArrayCollection[Event] |
||
120 | * @ORM\ManyToMany(targetEntity="Event", inversedBy="users") |
||
121 | */ |
||
122 | private $events; |
||
123 | |||
124 | /** |
||
125 | * @var ArrayCollection[FormRequest] |
||
126 | * @ORM\OneToMany(targetEntity="FormRequest", mappedBy="user") |
||
127 | */ |
||
128 | private $formRequests; |
||
129 | |||
130 | /** |
||
131 | * @var ArrayCollection[Survey] |
||
132 | * @ORM\OneToMany(targetEntity="Survey", mappedBy="user") |
||
133 | */ |
||
134 | private $surveys; |
||
135 | |||
136 | /** |
||
137 | * @var ArrayCollection[SurveyAnswer] |
||
138 | * @ORM\OneToMany(targetEntity="SurveyAnswer", mappedBy="user") |
||
139 | */ |
||
140 | private $answers; |
||
141 | |||
142 | public function __construct() |
||
143 | { |
||
144 | $this->events = new ArrayCollection(); |
||
145 | $this->formRequests = new ArrayCollection(); |
||
146 | $this->surveys = new ArrayCollection(); |
||
147 | $this->answers = new ArrayCollection(); |
||
148 | $this->roles = array('ROLE_USER'); |
||
149 | } |
||
150 | |||
151 | /** |
||
152 | * Get id. |
||
153 | * |
||
154 | * @return int |
||
155 | */ |
||
156 | public function getId() |
||
157 | { |
||
158 | return $this->id; |
||
159 | } |
||
160 | |||
161 | /** |
||
162 | * Get name. |
||
163 | * |
||
164 | * @return string |
||
165 | */ |
||
166 | public function getUsername() |
||
167 | { |
||
168 | return $this->email; |
||
169 | } |
||
170 | |||
171 | /** |
||
172 | * Set firstname. |
||
173 | * |
||
174 | * @param string $name |
||
175 | * |
||
176 | * @return User |
||
177 | */ |
||
178 | public function setFirstName($name) |
||
179 | { |
||
180 | $this->firstName = $name; |
||
181 | |||
182 | return $this; |
||
183 | } |
||
184 | |||
185 | /** |
||
186 | * Get first name. |
||
187 | * |
||
188 | * @return string |
||
189 | */ |
||
190 | public function getFirstName() |
||
191 | { |
||
192 | return $this->firstName; |
||
193 | } |
||
194 | |||
195 | /** |
||
196 | * Set lastName. |
||
197 | * |
||
198 | * @param string $lastName |
||
199 | * |
||
200 | * @return User |
||
201 | */ |
||
202 | public function setLastName($lastName) |
||
203 | { |
||
204 | $this->lastName = $lastName; |
||
205 | |||
206 | return $this; |
||
207 | } |
||
208 | |||
209 | /** |
||
210 | * Get lastName. |
||
211 | * |
||
212 | * @return string |
||
213 | */ |
||
214 | public function getLastName() |
||
215 | { |
||
216 | return $this->lastName; |
||
217 | } |
||
218 | |||
219 | /** |
||
220 | * Set image. |
||
221 | * |
||
222 | * @param string $image |
||
223 | * |
||
224 | * @return User |
||
225 | */ |
||
226 | public function setImage($image) |
||
227 | { |
||
228 | $this->image = $image; |
||
229 | |||
230 | return $this; |
||
231 | } |
||
232 | |||
233 | /** |
||
234 | * Get image. |
||
235 | * |
||
236 | * @return string |
||
237 | */ |
||
238 | public function getImage() |
||
239 | { |
||
240 | return $this->image; |
||
241 | } |
||
242 | |||
243 | /** |
||
244 | * Set email. |
||
245 | * |
||
246 | * @param string $email |
||
247 | * |
||
248 | * @return User |
||
249 | */ |
||
250 | public function setEmail($email) |
||
251 | { |
||
252 | $this->email = $email; |
||
253 | |||
254 | return $this; |
||
255 | } |
||
256 | |||
257 | /** |
||
258 | * Get email. |
||
259 | * |
||
260 | * @return string |
||
261 | */ |
||
262 | public function getEmail() |
||
263 | { |
||
264 | return $this->email; |
||
265 | } |
||
266 | |||
267 | /** |
||
268 | * Set password. |
||
269 | * |
||
270 | * @param string $password |
||
271 | * |
||
272 | * @return User |
||
273 | */ |
||
274 | public function setPassword($password) |
||
275 | { |
||
276 | $this->password = $password; |
||
277 | |||
278 | return $this; |
||
279 | } |
||
280 | |||
281 | /** |
||
282 | * Get password. |
||
283 | * |
||
284 | * @return string |
||
285 | */ |
||
286 | public function getPassword() |
||
287 | { |
||
288 | return $this->password; |
||
289 | } |
||
290 | |||
291 | /** |
||
292 | * @return string |
||
293 | */ |
||
294 | public function getPlainPassword() |
||
295 | { |
||
296 | return $this->plainPassword; |
||
297 | } |
||
298 | |||
299 | /** |
||
300 | * @param string $plainPassword |
||
301 | */ |
||
302 | public function setPlainPassword($plainPassword) |
||
303 | { |
||
304 | $this->plainPassword = $plainPassword; |
||
305 | } |
||
306 | |||
307 | /** |
||
308 | * @param bool $status |
||
309 | * |
||
310 | * @return $this |
||
311 | */ |
||
312 | public function setStatus($status) |
||
313 | { |
||
314 | $this->isActive = $status; |
||
315 | |||
316 | return $this; |
||
317 | } |
||
318 | |||
319 | /** |
||
320 | * @return bool |
||
321 | */ |
||
322 | public function isEnabled() |
||
323 | { |
||
324 | return $this->isActive; |
||
325 | } |
||
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 | public function getRoles() |
||
339 | { |
||
340 | return $this->roles; |
||
341 | } |
||
342 | |||
343 | /** |
||
344 | * Set api token. |
||
345 | * |
||
346 | * @param string $apiToken |
||
347 | * |
||
348 | * @return User |
||
349 | */ |
||
350 | public function setApiToken($apiToken) |
||
351 | { |
||
352 | $this->apiToken = $apiToken; |
||
353 | |||
354 | return $this; |
||
355 | } |
||
356 | |||
357 | /** |
||
358 | * @return string |
||
359 | */ |
||
360 | public function getApiToken() |
||
361 | { |
||
362 | return $this->apiToken; |
||
363 | } |
||
364 | |||
365 | /** |
||
366 | * @param Event $event |
||
367 | * |
||
368 | * @return User |
||
369 | */ |
||
370 | public function setEvent($event) |
||
379 | |||
380 | /** |
||
381 | * @return ArrayCollection |
||
382 | */ |
||
383 | public function getEvents() |
||
384 | { |
||
385 | return $this->events; |
||
386 | } |
||
387 | |||
388 | /** |
||
389 | * @return ArrayCollection |
||
390 | */ |
||
391 | public function getFormRequests() |
||
395 | |||
396 | /** |
||
397 | * @return ArrayCollection |
||
398 | */ |
||
399 | public function getSurveys() |
||
403 | /** |
||
404 | * @return ArrayCollection |
||
405 | */ |
||
406 | public function getAnswers() |
||
410 | |||
411 | public function isAccountNonExpired() |
||
412 | { |
||
413 | return true; |
||
414 | } |
||
415 | |||
416 | public function isAccountNonLocked() |
||
417 | { |
||
418 | return true; |
||
419 | } |
||
420 | |||
421 | public function isCredentialsNonExpired() |
||
422 | { |
||
423 | return true; |
||
424 | } |
||
425 | |||
426 | public function getSalt() |
||
427 | { |
||
428 | // TODO: Implement getSalt() method. |
||
429 | } |
||
430 | |||
431 | public function eraseCredentials() |
||
432 | { |
||
433 | $this->setPlainPassword(null); |
||
434 | } |
||
435 | |||
436 | /** @see \Serializable::serialize() */ |
||
437 | public function serialize() |
||
447 | |||
448 | /** @see \Serializable::unserialize() */ |
||
449 | public function unserialize($serialized) |
||
458 | } |
||
459 |