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