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(targetEntity="AppBundle\Entity\S3\Image", cascade={"persist", "remove"}, fetch="EAGER", orphanRemoval=true) |
||
70 | * @Groups({"Short", "Detail"}) |
||
71 | */ |
||
72 | private $image; |
||
73 | |||
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 | */ |
||
110 | private $enabled = true; |
||
111 | |||
112 | /** |
||
113 | * @var |
||
114 | * @ORM\Column(type="json_array") |
||
115 | */ |
||
116 | protected $roles; |
||
117 | |||
118 | /** |
||
119 | * @var string |
||
120 | * |
||
121 | * @ORM\Column(type="string", unique=true, nullable=true) |
||
122 | */ |
||
123 | private $apiToken; |
||
124 | |||
125 | /** |
||
126 | * @var ArrayCollection[Event] |
||
127 | * @ORM\ManyToMany(targetEntity="Event", inversedBy="users", cascade={"persist", "remove"}) |
||
128 | * @Groups({"Detail"}) |
||
129 | */ |
||
130 | private $events; |
||
131 | |||
132 | /** |
||
133 | * @var ArrayCollection[FormRequest] |
||
134 | * @ORM\OneToMany(targetEntity="FormRequest", mappedBy="user") |
||
135 | * @Groups({"Detail"}) |
||
136 | */ |
||
137 | private $formRequests; |
||
138 | |||
139 | /** |
||
140 | * @var ArrayCollection[Survey] |
||
141 | * @ORM\OneToMany(targetEntity="Survey", mappedBy="user") |
||
142 | */ |
||
143 | private $surveys; |
||
144 | |||
145 | /** |
||
146 | * @var ArrayCollection[SurveyAnswer] |
||
147 | * @ORM\OneToMany(targetEntity="SurveyAnswer", mappedBy="user") |
||
148 | */ |
||
149 | private $answers; |
||
150 | |||
151 | 1 | public function __construct() |
|
152 | { |
||
153 | 1 | $this->events = new ArrayCollection(); |
|
154 | 1 | $this->formRequests = new ArrayCollection(); |
|
155 | 1 | $this->surveys = new ArrayCollection(); |
|
156 | 1 | $this->answers = new ArrayCollection(); |
|
157 | 1 | $this->roles = array('ROLE_USER'); |
|
158 | 1 | } |
|
159 | |||
160 | /** |
||
161 | * Get id. |
||
162 | * |
||
163 | * @return int |
||
164 | */ |
||
165 | 4 | public function getId() |
|
166 | { |
||
167 | 4 | return $this->id; |
|
168 | } |
||
169 | |||
170 | /** |
||
171 | * Get name. |
||
172 | * |
||
173 | * @return string |
||
174 | */ |
||
175 | 1 | public function getUsername() |
|
176 | { |
||
177 | 1 | return $this->email; |
|
178 | } |
||
179 | |||
180 | /** |
||
181 | * Set firstname. |
||
182 | * |
||
183 | * @param string $name |
||
184 | * |
||
185 | * @return User |
||
186 | */ |
||
187 | 2 | public function setFirstName($name) |
|
188 | { |
||
189 | 2 | $this->firstName = $name; |
|
190 | |||
191 | 2 | return $this; |
|
192 | } |
||
193 | |||
194 | /** |
||
195 | * Get first name. |
||
196 | * |
||
197 | * @return string |
||
198 | */ |
||
199 | 5 | public function getFirstName() |
|
200 | { |
||
201 | 5 | return $this->firstName; |
|
202 | } |
||
203 | |||
204 | /** |
||
205 | * Set lastName. |
||
206 | * |
||
207 | * @param string $lastName |
||
208 | * |
||
209 | * @return User |
||
210 | */ |
||
211 | 2 | public function setLastName($lastName) |
|
212 | { |
||
213 | 2 | $this->lastName = $lastName; |
|
214 | |||
215 | 2 | return $this; |
|
216 | } |
||
217 | |||
218 | /** |
||
219 | * Get lastName. |
||
220 | * |
||
221 | * @return string |
||
222 | */ |
||
223 | 5 | public function getLastName() |
|
224 | { |
||
225 | 5 | return $this->lastName; |
|
226 | } |
||
227 | |||
228 | /** |
||
229 | * Set image. |
||
230 | * |
||
231 | * @param string $image |
||
232 | * |
||
233 | * @return User |
||
234 | */ |
||
235 | public function setImage($image) |
||
236 | { |
||
237 | $this->image = $image; |
||
238 | |||
239 | return $this; |
||
240 | } |
||
241 | |||
242 | /** |
||
243 | * Get image. |
||
244 | * |
||
245 | * @return string |
||
246 | */ |
||
247 | 2 | public function getImage() |
|
248 | { |
||
249 | 2 | return $this->image; |
|
250 | } |
||
251 | |||
252 | /** |
||
253 | * Set email. |
||
254 | * |
||
255 | * @param string $email |
||
256 | * |
||
257 | * @return User |
||
258 | */ |
||
259 | 2 | public function setEmail($email) |
|
260 | { |
||
261 | 2 | $this->email = $email; |
|
262 | |||
263 | 2 | return $this; |
|
264 | } |
||
265 | |||
266 | /** |
||
267 | * Get email. |
||
268 | * |
||
269 | * @return string |
||
270 | */ |
||
271 | 5 | public function getEmail() |
|
272 | { |
||
273 | 5 | return $this->email; |
|
274 | } |
||
275 | |||
276 | /** |
||
277 | * Set password. |
||
278 | * |
||
279 | * @param string $password |
||
280 | * |
||
281 | * @return User |
||
282 | */ |
||
283 | 2 | public function setPassword($password) |
|
284 | { |
||
285 | 2 | $this->password = $password; |
|
286 | |||
287 | 2 | return $this; |
|
288 | } |
||
289 | |||
290 | /** |
||
291 | * Get password. |
||
292 | * |
||
293 | * @return string |
||
294 | */ |
||
295 | 1 | public function getPassword() |
|
296 | { |
||
297 | 1 | return $this->password; |
|
298 | } |
||
299 | |||
300 | /** |
||
301 | * @return string |
||
302 | */ |
||
303 | 4 | public function getPlainPassword() |
|
304 | { |
||
305 | 4 | return $this->plainPassword; |
|
306 | } |
||
307 | |||
308 | /** |
||
309 | * @param string $plainPassword |
||
310 | */ |
||
311 | 3 | public function setPlainPassword($plainPassword) |
|
312 | { |
||
313 | 3 | $this->plainPassword = $plainPassword; |
|
314 | 3 | } |
|
315 | |||
316 | /** |
||
317 | * @param mixed $roles |
||
318 | */ |
||
319 | public function setRoles($roles) |
||
320 | { |
||
321 | $this->roles = $roles; |
||
322 | } |
||
323 | |||
324 | /** |
||
325 | * @return mixed |
||
326 | */ |
||
327 | 1 | public function getRoles() |
|
328 | { |
||
329 | 1 | return $this->roles; |
|
330 | } |
||
331 | |||
332 | /** |
||
333 | * Set api token. |
||
334 | * |
||
335 | * @param string $apiToken |
||
336 | * |
||
337 | * @return User |
||
338 | */ |
||
339 | 1 | public function setApiToken($apiToken) |
|
340 | { |
||
341 | 1 | $this->apiToken = $apiToken; |
|
342 | |||
343 | 1 | return $this; |
|
344 | } |
||
345 | |||
346 | /** |
||
347 | * @return string |
||
348 | */ |
||
349 | public function getApiToken() |
||
350 | { |
||
351 | return $this->apiToken; |
||
352 | } |
||
353 | |||
354 | /** |
||
355 | * @param Event $event |
||
356 | * |
||
357 | * @return User |
||
358 | */ |
||
359 | public function setEvent($event) |
||
368 | |||
369 | /** |
||
370 | * @return ArrayCollection |
||
371 | */ |
||
372 | 1 | public function getEvents() |
|
373 | { |
||
374 | 1 | return $this->events; |
|
375 | } |
||
376 | |||
377 | /** |
||
378 | * @return ArrayCollection |
||
379 | */ |
||
380 | 1 | public function getFormRequests() |
|
381 | { |
||
382 | 1 | return $this->formRequests; |
|
383 | } |
||
384 | |||
385 | /** |
||
386 | * @return ArrayCollection |
||
387 | */ |
||
388 | public function getSurveys() |
||
392 | /** |
||
393 | * @return ArrayCollection |
||
394 | */ |
||
395 | public function getAnswers() |
||
396 | { |
||
397 | return $this->answers; |
||
398 | } |
||
399 | |||
400 | /** |
||
401 | * Set enabled |
||
402 | * |
||
403 | * @param boolean $enabled |
||
404 | * |
||
405 | * @return User |
||
406 | */ |
||
407 | 1 | public function setEnabled(bool $enabled) |
|
408 | { |
||
409 | 1 | $this->enabled = $enabled; |
|
410 | |||
411 | 1 | return $this; |
|
412 | } |
||
413 | |||
414 | /** |
||
415 | * Get enabled |
||
416 | * |
||
417 | * @return boolean |
||
418 | */ |
||
419 | 3 | public function isEnabled() |
|
423 | |||
424 | 2 | public function getSalt() |
|
428 | |||
429 | 1 | public function eraseCredentials() |
|
433 | |||
434 | /** @see \Serializable::serialize() */ |
||
435 | public function serialize() |
||
445 | |||
446 | /** @see \Serializable::unserialize() */ |
||
447 | public function unserialize($serialized) |
||
456 | } |
||
457 |