1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This file is part of the login-cidadao project or it's bundles. |
4
|
|
|
* |
5
|
|
|
* (c) Guilherme Donato <guilhermednt on github> |
6
|
|
|
* |
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
8
|
|
|
* file that was distributed with this source code. |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace LoginCidadao\CoreBundle\Entity; |
12
|
|
|
|
13
|
|
|
use Doctrine\ORM\Mapping as ORM; |
14
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
15
|
|
|
use Doctrine\Common\Collections\Collection; |
16
|
|
|
use libphonenumber\PhoneNumber; |
17
|
|
|
use LoginCidadao\BadgesControlBundle\Model\BadgeInterface; |
18
|
|
|
use Symfony\Component\HttpFoundation\File\File; |
19
|
|
|
use Symfony\Component\Validator\Constraints as Assert; |
20
|
|
|
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; |
21
|
|
|
use Scheb\TwoFactorBundle\Model\BackupCodeInterface; |
22
|
|
|
use Vich\UploaderBundle\Mapping\Annotation as Vich; |
23
|
|
|
use JMS\Serializer\Annotation as JMS; |
24
|
|
|
use FOS\UserBundle\Model\User as BaseUser; |
25
|
|
|
use LoginCidadao\OAuthBundle\Entity\Client; |
26
|
|
|
use LoginCidadao\CoreBundle\Model\LocationSelectData; |
27
|
|
|
use LoginCidadao\CoreBundle\Model\PersonInterface; |
28
|
|
|
use LoginCidadao\OAuthBundle\Model\ClientInterface; |
29
|
|
|
use LoginCidadao\ValidationBundle\Validator\Constraints as LCAssert; |
30
|
|
|
use Donato\PathWellBundle\Validator\Constraints\PathWell; |
31
|
|
|
use Misd\PhoneNumberBundle\Validator\Constraints\PhoneNumber as AssertPhoneNumber; |
32
|
|
|
use Rollerworks\Component\PasswordStrength\Validator\Constraints as RollerworksPassword; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @ORM\Entity(repositoryClass="LoginCidadao\CoreBundle\Entity\PersonRepository") |
36
|
|
|
* @ORM\Table(name="person") |
37
|
|
|
* @UniqueEntity("cpf", message="person.validation.cpf.already_used", groups={"LoginCidadaoRegistration", "Registration", "Profile", "LoginCidadaoProfile", "Dynamic", "Documents"}) |
38
|
|
|
* @UniqueEntity("username") |
39
|
|
|
* @UniqueEntity(fields="emailCanonical", errorPath="email", message="fos_user.email.already_used", groups={"LoginCidadaoRegistration", "Registration", "LoginCidadaoEmailForm", "LoginCidadaoProfile", "Dynamic"}) |
40
|
|
|
* @ORM\HasLifecycleCallbacks |
41
|
|
|
* @JMS\ExclusionPolicy("all") |
42
|
|
|
* @Vich\Uploadable |
43
|
|
|
*/ |
44
|
|
|
class Person extends BaseUser implements PersonInterface, BackupCodeInterface |
45
|
|
|
{ |
46
|
|
|
/** |
47
|
|
|
* @ORM\Id |
48
|
|
|
* @ORM\Column(type="integer") |
49
|
|
|
* @ORM\GeneratedValue(strategy="AUTO") |
50
|
|
|
* @JMS\Since("1.0") |
51
|
|
|
* @JMS\Until("2") |
52
|
|
|
*/ |
53
|
|
|
protected $id; |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @JMS\Expose |
57
|
|
|
* @JMS\Groups({"first_name","full_name","public_profile","given_name","name"}) |
58
|
|
|
* @ORM\Column(type="string", nullable=true) |
59
|
|
|
* @Assert\NotBlank(message="Please enter your name.", groups={"Profile", "LoginCidadaoProfile"}) |
60
|
|
|
* @Assert\Length( |
61
|
|
|
* min=3, |
62
|
|
|
* max="255", |
63
|
|
|
* minMessage="The name is too short.", |
64
|
|
|
* maxMessage="The name is too long.", |
65
|
|
|
* groups={"Registration", "Profile", "LoginCidadaoProfile"} |
66
|
|
|
* ) |
67
|
|
|
* @JMS\Since("1.0") |
68
|
|
|
*/ |
69
|
|
|
protected $firstName; |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* @JMS\Expose |
73
|
|
|
* @JMS\Groups({"last_name","full_name","family_name","middle_name","name"}) |
74
|
|
|
* @ORM\Column(type="string", nullable=true) |
75
|
|
|
* @Assert\NotBlank(message="Please enter your surname.", groups={"Profile", "LoginCidadaoProfile"}) |
76
|
|
|
* @Assert\Length( |
77
|
|
|
* min=1, |
78
|
|
|
* max="255", |
79
|
|
|
* minMessage="The surname is too short.", |
80
|
|
|
* maxMessage="The surname is too long.", |
81
|
|
|
* groups={"Registration", "Profile", "LoginCidadaoProfile"} |
82
|
|
|
* ) |
83
|
|
|
* @JMS\Since("1.0") |
84
|
|
|
*/ |
85
|
|
|
protected $surname; |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* @JMS\Expose |
89
|
|
|
* @JMS\Groups({"username","preferred_username"}) |
90
|
|
|
* @Assert\NotBlank |
91
|
|
|
* @Assert\Length( |
92
|
|
|
* min="1", |
93
|
|
|
* max="40", |
94
|
|
|
* groups={"Registration", "Profile", "LoginCidadaoProfile"} |
95
|
|
|
* ) |
96
|
|
|
* @JMS\Since("1.0") |
97
|
|
|
*/ |
98
|
|
|
protected $username; |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* @JMS\Exclude |
102
|
|
|
* @PathWell( |
103
|
|
|
* groups={"Registration", "ResetPassword", "ChangePassword", "LoginCidadaoRegistration"} |
104
|
|
|
* ) |
105
|
|
|
* @RollerworksPassword\PasswordRequirements( |
106
|
|
|
* minLength=false, |
107
|
|
|
* requireLetters=true, |
108
|
|
|
* requireNumbers=true, |
109
|
|
|
* missingLettersMessage="person.validation.password.missingLetters", |
110
|
|
|
* missingNumbersMessage="person.validation.password.missingNumbers", |
111
|
|
|
* groups={"Registration", "ResetPassword", "ChangePassword", "LoginCidadaoRegistration"} |
112
|
|
|
* ) |
113
|
|
|
* @Assert\Length( |
114
|
|
|
* min=8, |
115
|
|
|
* max=72, |
116
|
|
|
* maxMessage="person.validation.password.length.max", |
117
|
|
|
* minMessage="person.validation.password.length.min", |
118
|
|
|
* groups={"Registration", "ResetPassword", "ChangePassword", "LoginCidadaoRegistration"} |
119
|
|
|
* ) |
120
|
|
|
* @Assert\NotBlank(message="person.validation.password.not_blank", groups={"Registration", "ResetPassword", "ChangePassword", "LoginCidadaoRegistration"}) |
121
|
|
|
*/ |
122
|
|
|
protected $plainPassword; |
123
|
|
|
|
124
|
|
|
/** |
125
|
|
|
* @JMS\Expose |
126
|
|
|
* @JMS\Groups({"cpf"}) |
127
|
|
|
* @ORM\Column(type="string", nullable=true, unique=true) |
128
|
|
|
* @LCAssert\CPF(groups={"Documents", "Dynamic", "LoginCidadaoRegistration"}) |
129
|
|
|
* @JMS\Since("1.0") |
130
|
|
|
*/ |
131
|
|
|
protected $cpf; |
132
|
|
|
|
133
|
|
|
/** |
134
|
|
|
* @JMS\Expose |
135
|
|
|
* @JMS\Groups({"email"}) |
136
|
|
|
* @JMS\Since("1.0") |
137
|
|
|
* @LCAssert\Email(strict=true, groups={"Profile", "LoginCidadaoProfile", "Registration", "ResetPassword", "ChangePassword", "LoginCidadaoRegistration", "LoginCidadaoEmailForm"}) |
138
|
|
|
* @Assert\NotBlank(message="person.validation.email.not_blank", groups={"Profile", "LoginCidadaoProfile", "Registration", "ResetPassword", "ChangePassword", "LoginCidadaoRegistration", "LoginCidadaoEmailForm"}) |
139
|
|
|
*/ |
140
|
|
|
protected $email; |
141
|
|
|
|
142
|
|
|
/** |
143
|
|
|
* @JMS\Expose |
144
|
|
|
* @JMS\Groups({"birthdate"}) |
145
|
|
|
* @ORM\Column(type="date", nullable=true) |
146
|
|
|
* @JMS\Since("1.0") |
147
|
|
|
* @LCAssert\Age(max="150", groups={"Profile", "LoginCidadaoProfile", "Registration", "ResetPassword", "ChangePassword", "LoginCidadaoRegistration", "LoginCidadaoEmailForm"}) |
148
|
|
|
*/ |
149
|
|
|
protected $birthdate; |
150
|
|
|
|
151
|
|
|
/** |
152
|
|
|
* @ORM\Column(name="email_expiration", type="datetime", nullable=true) |
153
|
|
|
* @JMS\Since("1.0") |
154
|
|
|
*/ |
155
|
|
|
protected $emailExpiration; |
156
|
|
|
|
157
|
|
|
/** |
158
|
|
|
* @JMS\Expose |
159
|
|
|
* @JMS\Groups({"mobile","phone_number"}) |
160
|
|
|
* @JMS\Type("libphonenumber\PhoneNumber") |
161
|
|
|
* @ORM\Column(type="phone_number", nullable=true) |
162
|
|
|
* @JMS\Since("1.0") |
163
|
|
|
* @LCAssert\E164PhoneNumber( |
164
|
|
|
* maxMessage="person.validation.mobile.length.max", |
165
|
|
|
* groups={"Registration", "LoginCidadaoRegistration", "Dynamic", "Profile", "LoginCidadaoProfile"} |
166
|
|
|
* ) |
167
|
|
|
* @LCAssert\MobilePhoneNumber( |
168
|
|
|
* missing9thDigit="person.validation.mobile.9thDigit", |
169
|
|
|
* groups={"Registration", "LoginCidadaoRegistration", "Dynamic", "Profile", "LoginCidadaoProfile"} |
170
|
|
|
* ) |
171
|
|
|
* @AssertPhoneNumber( |
172
|
|
|
* type="mobile", |
173
|
|
|
* groups={"Registration", "LoginCidadaoRegistration", "Dynamic", "Profile", "LoginCidadaoProfile"} |
174
|
|
|
* ) |
175
|
|
|
*/ |
176
|
|
|
protected $mobile; |
177
|
|
|
|
178
|
|
|
/** |
179
|
|
|
* @ORM\Column(type="string", length=255, nullable=true) |
180
|
|
|
* @var string |
181
|
|
|
* @JMS\Since("1.0") |
182
|
|
|
*/ |
183
|
|
|
protected $twitterPicture; |
184
|
|
|
|
185
|
|
|
/** |
186
|
|
|
* @JMS\Expose |
187
|
|
|
* @JMS\Groups({"city"}) |
188
|
|
|
* @ORM\ManyToOne(targetEntity="LoginCidadao\CoreBundle\Entity\City") |
189
|
|
|
* @ORM\JoinColumn(name="city_id", referencedColumnName="id") |
190
|
|
|
* @JMS\Since("1.0") |
191
|
|
|
*/ |
192
|
|
|
protected $city; |
193
|
|
|
|
194
|
|
|
/** |
195
|
|
|
* @var string |
196
|
|
|
* |
197
|
|
|
* @ORM\Column(name="facebookId", type="string", length=255, nullable=true, unique=true) |
198
|
|
|
* @JMS\Exclude |
199
|
|
|
*/ |
200
|
|
|
protected $facebookId; |
201
|
|
|
|
202
|
|
|
/** |
203
|
|
|
* @var string |
204
|
|
|
* |
205
|
|
|
* @ORM\Column(name="facebookUsername", type="string", length=255, nullable=true) |
206
|
|
|
* @JMS\Exclude |
207
|
|
|
*/ |
208
|
|
|
protected $facebookUsername; |
209
|
|
|
|
210
|
|
|
/** |
211
|
|
|
* @var string |
212
|
|
|
* |
213
|
|
|
* @ORM\Column(name="facebookAccessToken", type="string", length=255, nullable=true) |
214
|
|
|
* @JMS\Exclude() |
215
|
|
|
*/ |
216
|
|
|
protected $facebookAccessToken; |
217
|
|
|
|
218
|
|
|
/** |
219
|
|
|
* @var string |
220
|
|
|
* |
221
|
|
|
* @ORM\Column(name="twitterId", type="string", length=255, nullable=true, unique=true) |
222
|
|
|
* @JMS\Exclude |
223
|
|
|
*/ |
224
|
|
|
protected $twitterId; |
225
|
|
|
|
226
|
|
|
/** |
227
|
|
|
* @var string |
228
|
|
|
* |
229
|
|
|
* @ORM\Column(name="twitterUsername", type="string", length=255, nullable=true) |
230
|
|
|
* @JMS\Exclude |
231
|
|
|
*/ |
232
|
|
|
protected $twitterUsername; |
233
|
|
|
|
234
|
|
|
/** |
235
|
|
|
* @var string |
236
|
|
|
* |
237
|
|
|
* @ORM\Column(name="twitterAccessToken", type="string", length=255, nullable=true) |
238
|
|
|
* @JMS\Exclude |
239
|
|
|
*/ |
240
|
|
|
protected $twitterAccessToken; |
241
|
|
|
|
242
|
|
|
/** |
243
|
|
|
* @ORM\OneToMany(targetEntity="Authorization", mappedBy="person", cascade={"remove"}, orphanRemoval=true) |
244
|
|
|
*/ |
245
|
|
|
protected $authorizations; |
246
|
|
|
|
247
|
|
|
/** |
248
|
|
|
* @ORM\Column(type="datetime", nullable=false) |
249
|
|
|
* @var \DateTime |
250
|
|
|
* @JMS\Since("1.0") |
251
|
|
|
*/ |
252
|
|
|
protected $createdAt; |
253
|
|
|
|
254
|
|
|
/** |
255
|
|
|
* @ORM\Column(type="datetime", nullable=true) |
256
|
|
|
* @var \DateTime |
257
|
|
|
* @JMS\Since("1.0") |
258
|
|
|
*/ |
259
|
|
|
protected $emailConfirmedAt; |
260
|
|
|
|
261
|
|
|
/** |
262
|
|
|
* @ORM\Column(type="string", length=255, nullable=true) |
263
|
|
|
* @var string |
264
|
|
|
* @JMS\Since("1.0") |
265
|
|
|
*/ |
266
|
|
|
protected $previousValidEmail; |
267
|
|
|
|
268
|
|
|
/** |
269
|
|
|
* @ORM\ManyToMany(targetEntity="LoginCidadao\OAuthBundle\Entity\Client", mappedBy="owners") |
270
|
|
|
*/ |
271
|
|
|
protected $clients; |
272
|
|
|
|
273
|
|
|
/** |
274
|
|
|
* @ORM\OneToMany(targetEntity="ClientSuggestion", mappedBy="person") |
275
|
|
|
*/ |
276
|
|
|
protected $suggestions; |
277
|
|
|
|
278
|
|
|
/** |
279
|
|
|
* @JMS\Expose |
280
|
|
|
* @JMS\Groups({"state"}) |
281
|
|
|
* @ORM\ManyToOne(targetEntity="LoginCidadao\CoreBundle\Entity\State") |
282
|
|
|
* @ORM\JoinColumn(name="state_id", referencedColumnName="id") |
283
|
|
|
* @JMS\Since("1.0.2") |
284
|
|
|
*/ |
285
|
|
|
protected $state; |
286
|
|
|
|
287
|
|
|
/** |
288
|
|
|
* @JMS\Expose |
289
|
|
|
* @JMS\Groups({"country"}) |
290
|
|
|
* @ORM\ManyToOne(targetEntity="LoginCidadao\CoreBundle\Entity\Country") |
291
|
|
|
* @ORM\JoinColumn(name="country_id", referencedColumnName="id") |
292
|
|
|
* @JMS\Since("1.0.2") |
293
|
|
|
*/ |
294
|
|
|
protected $country; |
295
|
|
|
|
296
|
|
|
/** |
297
|
|
|
* @Assert\File( |
298
|
|
|
* maxSize="2M", |
299
|
|
|
* maxSizeMessage="The maxmimum allowed file size is 2MB.", |
300
|
|
|
* mimeTypes={"image/png", "image/jpeg", "image/pjpeg"}, |
301
|
|
|
* mimeTypesMessage="Only JPEG and PNG images are allowed." |
302
|
|
|
* ) |
303
|
|
|
* @Vich\UploadableField(mapping="user_image", fileNameProperty="imageName") |
304
|
|
|
* @var File $image |
305
|
|
|
* @JMS\Since("1.0.2") |
306
|
|
|
*/ |
307
|
|
|
protected $image; |
308
|
|
|
|
309
|
|
|
/** |
310
|
|
|
* @ORM\Column(type="string", length=255, name="image_name", nullable=true) |
311
|
|
|
* |
312
|
|
|
* @var string $imageName |
313
|
|
|
* @JMS\Since("1.0.2") |
314
|
|
|
*/ |
315
|
|
|
protected $imageName; |
316
|
|
|
|
317
|
|
|
/** |
318
|
|
|
* @JMS\Expose |
319
|
|
|
* @JMS\Groups({"public_profile","picture"}) |
320
|
|
|
* @JMS\Since("1.0.2") |
321
|
|
|
* @JMS\Until("2") |
322
|
|
|
*/ |
323
|
|
|
protected $profilePictureUrl; |
324
|
|
|
|
325
|
|
|
/** |
326
|
|
|
* @ORM\Column(type="datetime", nullable=true) |
327
|
|
|
* @JMS\Expose |
328
|
|
|
* @JMS\Groups({"public_profile","updated_at"}) |
329
|
|
|
* @var \DateTime $updatedAt |
330
|
|
|
* @JMS\Since("1.0.2") |
331
|
|
|
*/ |
332
|
|
|
protected $updatedAt; |
333
|
|
|
|
334
|
|
|
/** |
335
|
|
|
* @var string |
336
|
|
|
* |
337
|
|
|
* @ORM\Column(name="googleId", type="string", length=255, nullable=true, unique=true) |
338
|
|
|
* @JMS\Exclude |
339
|
|
|
*/ |
340
|
|
|
protected $googleId; |
341
|
|
|
|
342
|
|
|
/** |
343
|
|
|
* @var string |
344
|
|
|
* |
345
|
|
|
* @ORM\Column(name="googleUsername", type="string", length=255, nullable=true) |
346
|
|
|
* @JMS\Exclude |
347
|
|
|
*/ |
348
|
|
|
protected $googleUsername; |
349
|
|
|
|
350
|
|
|
/** |
351
|
|
|
* @var string |
352
|
|
|
* |
353
|
|
|
* @ORM\Column(name="googleAccessToken", type="string", length=255, nullable=true) |
354
|
|
|
* @JMS\Exclude |
355
|
|
|
*/ |
356
|
|
|
protected $googleAccessToken; |
357
|
|
|
|
358
|
|
|
/** |
359
|
|
|
* @JMS\Expose |
360
|
|
|
* @JMS\Groups({"id_cards"}) |
361
|
|
|
* @ORM\OneToMany(targetEntity="LoginCidadao\CoreBundle\Entity\IdCard", mappedBy="person") |
362
|
|
|
* @JMS\Since("1.0.3") |
363
|
|
|
*/ |
364
|
|
|
protected $idCards; |
365
|
|
|
|
366
|
|
|
/** |
367
|
|
|
* @JMS\Expose |
368
|
|
|
* @JMS\Groups({"public_profile"}) |
369
|
|
|
* @JMS\Type("array<LoginCidadao\BadgesControlBundle\Model\Badge>") |
370
|
|
|
* @JMS\Since("2") |
371
|
|
|
* @JMS\Until("3") |
372
|
|
|
* @deprecated Use RemoteClaims instead |
373
|
|
|
* @var array|BadgeInterface[] |
374
|
|
|
*/ |
375
|
|
|
protected $badges = []; |
376
|
|
|
|
377
|
|
|
/** |
378
|
|
|
* @ORM\OneToMany(targetEntity="LoginCidadao\APIBundle\Entity\LogoutKey", mappedBy="person", cascade={"remove"}, orphanRemoval=true) |
379
|
|
|
*/ |
380
|
|
|
protected $logoutKeys; |
381
|
|
|
|
382
|
|
|
/** |
383
|
|
|
* @JMS\Expose |
384
|
|
|
* @JMS\Groups({"addresses","address"}) |
385
|
|
|
* @ORM\OneToMany(targetEntity="LoginCidadao\CoreBundle\Entity\PersonAddress", mappedBy="person", cascade={"remove"}, orphanRemoval=true) |
386
|
|
|
*/ |
387
|
|
|
protected $addresses; |
388
|
|
|
|
389
|
|
|
/** |
390
|
|
|
* @ORM\Column(name="google_authenticator_secret", type="string", nullable=true) |
391
|
|
|
* @JMS\Exclude |
392
|
|
|
*/ |
393
|
|
|
protected $googleAuthenticatorSecret; |
394
|
|
|
|
395
|
|
|
/** |
396
|
|
|
* @JMS\Expose |
397
|
|
|
* @JMS\Groups({"nationality"}) |
398
|
|
|
* @ORM\ManyToOne(targetEntity="LoginCidadao\CoreBundle\Entity\Country") |
399
|
|
|
* @ORM\JoinColumn(name="nationality_id", referencedColumnName="id") |
400
|
|
|
* @JMS\Since("1.0.2") |
401
|
|
|
*/ |
402
|
|
|
protected $nationality; |
403
|
|
|
|
404
|
|
|
/** |
405
|
|
|
* @var BackupCode[]|ArrayCollection |
406
|
|
|
* |
407
|
|
|
* @JMS\Exclude |
408
|
|
|
* @ORM\OneToMany(targetEntity="BackupCode", mappedBy="person", cascade={"remove"}, orphanRemoval=true) |
409
|
|
|
*/ |
410
|
|
|
protected $backupCodes; |
411
|
|
|
|
412
|
|
|
/** |
413
|
|
|
* @JMS\Exclude |
414
|
|
|
* @ORM\Column(name="password_encoder_name", type="string", length=255, nullable=true) |
415
|
|
|
*/ |
416
|
|
|
protected $passwordEncoderName; |
417
|
|
|
|
418
|
|
|
/** |
419
|
|
|
* @JMS\Expose |
420
|
|
|
* @JMS\Groups({"public_profile"}) |
421
|
|
|
* @JMS\SerializedName("phone_number_verified") |
422
|
|
|
* @JMS\Since("1.1") |
423
|
|
|
* @var bool |
424
|
|
|
*/ |
425
|
|
|
protected $phoneNumberVerified = false; |
426
|
|
|
|
427
|
51 |
|
public function __construct() |
428
|
|
|
{ |
429
|
51 |
|
parent::__construct(); |
430
|
51 |
|
$this->authorizations = new ArrayCollection(); |
431
|
51 |
|
$this->clients = new ArrayCollection(); |
432
|
51 |
|
$this->logoutKeys = new ArrayCollection(); |
433
|
51 |
|
$this->addresses = new ArrayCollection(); |
434
|
51 |
|
$this->backupCodes = new ArrayCollection(); |
435
|
51 |
|
} |
436
|
|
|
|
437
|
2 |
|
public function getEmail() |
438
|
|
|
{ |
439
|
2 |
|
return $this->email; |
440
|
|
|
} |
441
|
|
|
|
442
|
3 |
|
public function setEmail($email) |
443
|
|
|
{ |
444
|
3 |
|
$this->email = $email; |
445
|
|
|
|
446
|
3 |
|
return $this; |
447
|
|
|
} |
448
|
|
|
|
449
|
3 |
|
public function getFirstName() |
450
|
|
|
{ |
451
|
3 |
|
return $this->firstName; |
452
|
|
|
} |
453
|
|
|
|
454
|
1 |
|
public function setFirstName($firstName) |
455
|
|
|
{ |
456
|
1 |
|
$this->firstName = $firstName; |
457
|
|
|
|
458
|
1 |
|
return $this; |
459
|
|
|
} |
460
|
|
|
|
461
|
3 |
|
public function getSurname() |
462
|
|
|
{ |
463
|
3 |
|
return $this->surname; |
464
|
|
|
} |
465
|
|
|
|
466
|
1 |
|
public function setSurname($suname) |
467
|
|
|
{ |
468
|
1 |
|
$this->surname = $suname; |
469
|
|
|
|
470
|
1 |
|
return $this; |
471
|
|
|
} |
472
|
|
|
|
473
|
2 |
|
public function getBirthdate() |
474
|
|
|
{ |
475
|
2 |
|
return $this->birthdate; |
476
|
|
|
} |
477
|
|
|
|
478
|
|
|
public function setBirthdate($birthdate) |
479
|
|
|
{ |
480
|
|
|
$this->birthdate = $birthdate; |
481
|
|
|
|
482
|
|
|
return $this; |
483
|
|
|
} |
484
|
|
|
|
485
|
9 |
|
public function getMobile() |
486
|
|
|
{ |
487
|
9 |
|
return $this->mobile; |
488
|
|
|
} |
489
|
|
|
|
490
|
6 |
|
public function setMobile($mobile) |
491
|
|
|
{ |
492
|
6 |
|
if (!($mobile instanceof PhoneNumber)) { |
493
|
1 |
|
$mobile = preg_replace('/[^0-9+]/', '', $mobile); |
494
|
|
|
|
495
|
|
|
// PhoneNumberBundle won't work with empty strings. |
496
|
|
|
// See https://github.com/misd-service-development/phone-number-bundle/issues/58 |
497
|
1 |
|
if (strlen(trim($mobile)) === 0) { |
498
|
1 |
|
$mobile = null; |
499
|
|
|
} |
500
|
|
|
} |
501
|
6 |
|
$this->mobile = $mobile; |
502
|
|
|
|
503
|
6 |
|
return $this; |
504
|
|
|
} |
505
|
|
|
|
506
|
|
|
public function addAuthorization(Authorization $authorization) |
507
|
|
|
{ |
508
|
|
|
$this->authorizations->add($authorization); |
509
|
|
|
$authorization->setPerson($this); |
510
|
|
|
|
511
|
|
|
return $this; |
512
|
|
|
} |
513
|
|
|
|
514
|
|
|
public function removeAuthorization(Authorization $authorization) |
515
|
|
|
{ |
516
|
|
|
if ($this->authorizations->contains($authorization)) { |
517
|
|
|
$this->authorizations->removeElement($authorization); |
518
|
|
|
} |
519
|
|
|
|
520
|
|
|
return $this; |
521
|
|
|
} |
522
|
|
|
|
523
|
|
|
/** |
524
|
|
|
* @return Authorization[]|ArrayCollection |
525
|
|
|
*/ |
526
|
|
|
public function getAuthorizations($uidToIgnore = null) |
527
|
|
|
{ |
528
|
|
|
if ($uidToIgnore !== null) { |
529
|
|
|
return array_filter( |
530
|
|
|
$this->authorizations->toArray(), |
531
|
|
|
function (Authorization $authorization) use ($uidToIgnore) { |
532
|
|
|
return $authorization->getClient()->getUid() != $uidToIgnore; |
533
|
|
|
} |
534
|
|
|
); |
535
|
|
|
} |
536
|
|
|
|
537
|
|
|
return $this->authorizations; |
538
|
|
|
} |
539
|
|
|
|
540
|
|
|
/** |
541
|
|
|
* Checks if a given Client can access this Person's specified scope. |
542
|
|
|
* @param ClientInterface $client |
543
|
|
|
* @param mixed $scope can be a single scope or an array with several. |
544
|
|
|
* @return boolean |
545
|
|
|
*/ |
546
|
|
|
public function isAuthorizedClient(ClientInterface $client, $scope) |
547
|
|
|
{ |
548
|
|
|
$authorizations = $this->getAuthorizations(); |
549
|
|
|
foreach ($authorizations as $auth) { |
550
|
|
|
$c = $auth->getClient(); |
551
|
|
|
if ($c->getId() == $client->getId()) { |
552
|
|
|
return $auth->hasScopes($scope); |
553
|
|
|
} |
554
|
|
|
} |
555
|
|
|
|
556
|
|
|
return false; |
557
|
|
|
} |
558
|
|
|
|
559
|
|
|
/** |
560
|
|
|
* @param Client $client |
561
|
|
|
* @return array |
562
|
|
|
*/ |
563
|
|
|
public function getClientScope(Client $client) |
564
|
|
|
{ |
565
|
|
|
$authorizations = $this->getAuthorizations(); |
566
|
|
|
foreach ($authorizations as $auth) { |
567
|
|
|
$c = $auth->getClient(); |
568
|
|
|
if ($c->getId() == $client->getId()) { |
569
|
|
|
return $auth->getScope(); |
570
|
|
|
} |
571
|
|
|
} |
572
|
|
|
|
573
|
|
|
return null; |
574
|
|
|
} |
575
|
|
|
|
576
|
|
|
/** |
577
|
|
|
* Checks if this Person has any authorization for a given Client. |
578
|
|
|
* WARNING: Note that it does NOT validate scope! |
579
|
|
|
* @param \LoginCidadao\OAuthBundle\Entity\Client | integer $client |
580
|
|
|
*/ |
581
|
|
|
public function hasAuthorization($client) |
582
|
|
|
{ |
583
|
|
|
if ($client instanceof ClientInterface) { |
584
|
|
|
$id = $client->getId(); |
585
|
|
|
} else { |
586
|
|
|
$id = $client; |
587
|
|
|
} |
588
|
|
|
$authorizations = $this->getAuthorizations(); |
589
|
|
|
if (is_array($authorizations) || $authorizations instanceof Collection) { |
|
|
|
|
590
|
|
|
foreach ($authorizations as $auth) { |
591
|
|
|
$c = $auth->getClient(); |
592
|
|
|
if ($c->getId() == $id) { |
593
|
|
|
return true; |
594
|
|
|
} |
595
|
|
|
} |
596
|
|
|
} |
597
|
|
|
|
598
|
|
|
return false; |
599
|
|
|
} |
600
|
|
|
|
601
|
|
|
public function setFacebookId($facebookId) |
602
|
|
|
{ |
603
|
|
|
$this->facebookId = $facebookId; |
604
|
|
|
|
605
|
|
|
return $this; |
606
|
|
|
} |
607
|
|
|
|
608
|
|
|
public function getFacebookId() |
609
|
|
|
{ |
610
|
|
|
return $this->facebookId; |
611
|
|
|
} |
612
|
|
|
|
613
|
|
|
public function setTwitterId($twitterId) |
614
|
|
|
{ |
615
|
|
|
$this->twitterId = $twitterId; |
616
|
|
|
|
617
|
|
|
return $this; |
618
|
|
|
} |
619
|
|
|
|
620
|
|
|
public function getTwitterId() |
621
|
|
|
{ |
622
|
|
|
return $this->twitterId; |
623
|
|
|
} |
624
|
|
|
|
625
|
|
|
public function setTwitterUsername($twitterUsername) |
626
|
|
|
{ |
627
|
|
|
$this->twitterUsername = $twitterUsername; |
628
|
|
|
|
629
|
|
|
return $this; |
630
|
|
|
} |
631
|
|
|
|
632
|
|
|
public function getTwitterUsername() |
633
|
|
|
{ |
634
|
|
|
return $this->twitterUsername; |
635
|
|
|
} |
636
|
|
|
|
637
|
|
|
public function setTwitterAccessToken($twitterAccessToken) |
638
|
|
|
{ |
639
|
|
|
$this->twitterAccessToken = $twitterAccessToken; |
640
|
|
|
|
641
|
|
|
return $this; |
642
|
|
|
} |
643
|
|
|
|
644
|
|
|
public function getTwitterAccessToken() |
645
|
|
|
{ |
646
|
|
|
return $this->twitterAccessToken; |
647
|
|
|
} |
648
|
|
|
|
649
|
|
|
public function serialize() |
650
|
|
|
{ |
651
|
|
|
return serialize(array($this->facebookId, parent::serialize())); |
652
|
|
|
} |
653
|
|
|
|
654
|
|
|
public function unserialize($data) |
655
|
|
|
{ |
656
|
|
|
list($this->facebookId, $parentData) = unserialize($data); |
657
|
|
|
parent::unserialize($parentData); |
658
|
|
|
} |
659
|
|
|
|
660
|
|
|
/** |
661
|
|
|
* Get the full name of the user (first + last name) |
662
|
|
|
* @JMS\Groups({"full_name", "name"}) |
663
|
|
|
* @JMS\VirtualProperty |
664
|
|
|
* @JMS\SerializedName("full_name") |
665
|
|
|
* @return string |
666
|
|
|
*/ |
667
|
3 |
|
public function getFullName() |
668
|
|
|
{ |
669
|
3 |
|
$fullName = array(); |
670
|
3 |
|
if ($this->getFirstname() !== null) { |
671
|
1 |
|
$fullName[] = $this->getFirstname(); |
672
|
|
|
} |
673
|
3 |
|
if ($this->getSurname() !== null) { |
674
|
1 |
|
$fullName[] = $this->getSurname(); |
675
|
|
|
} |
676
|
|
|
|
677
|
3 |
|
if (count($fullName) > 0) { |
678
|
1 |
|
return implode(' ', $fullName); |
679
|
|
|
} else { |
680
|
2 |
|
return null; |
681
|
|
|
} |
682
|
|
|
} |
683
|
|
|
|
684
|
|
|
/** |
685
|
|
|
* Get the full name of the user (first + last name) |
686
|
|
|
* @JMS\Groups({"full_name", "name"}) |
687
|
|
|
* @JMS\VirtualProperty |
688
|
|
|
* @JMS\SerializedName("name") |
689
|
|
|
* @return string |
690
|
|
|
*/ |
691
|
|
|
public function getOIDCName() |
692
|
|
|
{ |
693
|
|
|
return $this->getFullName(); |
694
|
|
|
} |
695
|
|
|
|
696
|
|
|
/** |
697
|
|
|
* @JMS\Groups({"badges", "public_profile"}) |
698
|
|
|
* @JMS\VirtualProperty |
699
|
|
|
* @JMS\SerializedName("deprecated_badges") |
700
|
|
|
* @JMS\Until("2") |
701
|
|
|
* @return array |
702
|
|
|
*/ |
703
|
|
|
public function getDataValid() |
704
|
|
|
{ |
705
|
|
|
$terms['cpf'] = is_numeric($this->cpf); |
|
|
|
|
706
|
|
|
$terms['email'] = is_null($this->getConfirmationToken()); |
707
|
|
|
|
708
|
|
|
return $terms; |
709
|
|
|
} |
710
|
|
|
|
711
|
|
|
public function setCpf($cpf) |
712
|
|
|
{ |
713
|
|
|
$cpf = trim(preg_replace('/[^0-9]/', '', $cpf)); |
714
|
|
|
|
715
|
|
|
if ($cpf === '') { |
716
|
|
|
$cpf = null; |
717
|
|
|
} |
718
|
|
|
|
719
|
|
|
$this->cpf = $cpf; |
720
|
|
|
|
721
|
|
|
return $this; |
722
|
|
|
} |
723
|
|
|
|
724
|
3 |
|
public function getCpf() |
725
|
|
|
{ |
726
|
3 |
|
return $this->cpf; |
727
|
|
|
} |
728
|
|
|
|
729
|
|
|
/** |
730
|
|
|
* @param City $city |
731
|
|
|
* @return PersonInterface |
732
|
|
|
*/ |
733
|
1 |
|
public function setCity(City $city = null) |
734
|
|
|
{ |
735
|
1 |
|
$this->city = $city; |
736
|
|
|
|
737
|
1 |
|
return $this; |
738
|
|
|
} |
739
|
|
|
|
740
|
|
|
/** |
741
|
|
|
* @return City |
742
|
|
|
*/ |
743
|
2 |
|
public function getCity() |
744
|
|
|
{ |
745
|
2 |
|
return $this->city; |
746
|
|
|
} |
747
|
|
|
|
748
|
1 |
|
public function setCreatedAt(\DateTime $createdAt) |
749
|
|
|
{ |
750
|
1 |
|
$this->createdAt = $createdAt; |
751
|
|
|
|
752
|
1 |
|
return $this; |
753
|
|
|
} |
754
|
|
|
|
755
|
1 |
|
public function getCreatedAt() |
756
|
|
|
{ |
757
|
1 |
|
return $this->createdAt; |
758
|
|
|
} |
759
|
|
|
|
760
|
|
|
/** |
761
|
|
|
* @ORM\PrePersist |
762
|
|
|
*/ |
763
|
|
|
public function setCreatedAtValue() |
764
|
|
|
{ |
765
|
|
|
if (!($this->getCreatedAt() instanceof \DateTime)) { |
|
|
|
|
766
|
|
|
$this->createdAt = new \DateTime(); |
767
|
|
|
} |
768
|
|
|
if (!$this->updatedAt) { |
769
|
|
|
$this->updatedAt = new \DateTime(); |
770
|
|
|
} |
771
|
|
|
} |
772
|
|
|
|
773
|
3 |
|
public function setEmailConfirmedAt(\DateTime $emailConfirmedAt = null) |
774
|
|
|
{ |
775
|
3 |
|
$this->emailConfirmedAt = $emailConfirmedAt; |
776
|
|
|
|
777
|
3 |
|
return $this; |
778
|
|
|
} |
779
|
|
|
|
780
|
6 |
|
public function getEmailConfirmedAt() |
781
|
|
|
{ |
782
|
6 |
|
return $this->emailConfirmedAt; |
783
|
|
|
} |
784
|
|
|
|
785
|
|
|
public function getSocialNetworksPicture() |
786
|
|
|
{ |
787
|
|
|
if (!is_null($this->getFacebookId())) { |
|
|
|
|
788
|
|
|
return "https://graph.facebook.com/{$this->getFacebookId()}/picture?height=245&width=245"; |
789
|
|
|
} |
790
|
|
|
|
791
|
|
|
return null; |
792
|
|
|
} |
793
|
|
|
|
794
|
|
|
public function getClients() |
795
|
|
|
{ |
796
|
|
|
return $this->clients; |
797
|
|
|
} |
798
|
|
|
|
799
|
|
|
public function setClients($var) |
800
|
|
|
{ |
801
|
|
|
return $this->clients = $var; |
802
|
|
|
} |
803
|
|
|
|
804
|
|
|
public function setEmailExpiration($emailExpiration) |
805
|
|
|
{ |
806
|
|
|
$this->emailExpiration = $emailExpiration; |
807
|
|
|
|
808
|
|
|
return $this; |
809
|
|
|
} |
810
|
|
|
|
811
|
|
|
public function getEmailExpiration() |
812
|
|
|
{ |
813
|
|
|
return $this->emailExpiration; |
814
|
|
|
} |
815
|
|
|
|
816
|
|
|
public function setFacebookUsername($facebookUsername) |
817
|
|
|
{ |
818
|
|
|
$this->facebookUsername = $facebookUsername; |
819
|
|
|
|
820
|
|
|
return $this; |
821
|
|
|
} |
822
|
|
|
|
823
|
|
|
public function getFacebookUsername() |
824
|
|
|
{ |
825
|
|
|
return $this->facebookUsername; |
826
|
|
|
} |
827
|
|
|
|
828
|
|
|
public function getFacebookAccessToken() |
829
|
|
|
{ |
830
|
|
|
return $this->facebookAccessToken; |
831
|
|
|
} |
832
|
|
|
|
833
|
|
|
public function setFacebookAccessToken($facebookAccessToken) |
834
|
|
|
{ |
835
|
|
|
$this->facebookAccessToken = $facebookAccessToken; |
836
|
|
|
|
837
|
|
|
return $this; |
838
|
|
|
} |
839
|
|
|
|
840
|
|
|
public function setPreviousValidEmail($previousValidEmail) |
841
|
|
|
{ |
842
|
|
|
$this->previousValidEmail = $previousValidEmail; |
843
|
|
|
|
844
|
|
|
return $this; |
845
|
|
|
} |
846
|
|
|
|
847
|
|
|
public function getPreviousValidEmail() |
848
|
|
|
{ |
849
|
|
|
return $this->previousValidEmail; |
850
|
|
|
} |
851
|
|
|
|
852
|
|
|
public function hasPassword() |
853
|
|
|
{ |
854
|
|
|
$password = $this->getPassword(); |
855
|
|
|
|
856
|
|
|
return strlen($password) > 0; |
857
|
|
|
} |
858
|
|
|
|
859
|
1 |
|
public function setState(State $state = null) |
860
|
|
|
{ |
861
|
1 |
|
$this->state = $state; |
862
|
|
|
|
863
|
1 |
|
return $this; |
864
|
|
|
} |
865
|
|
|
|
866
|
2 |
|
public function getState() |
867
|
|
|
{ |
868
|
2 |
|
return $this->state; |
869
|
|
|
} |
870
|
|
|
|
871
|
|
|
/** |
872
|
|
|
* If manually uploading a file (i.e. not using Symfony Form) ensure an instance |
873
|
|
|
* of 'UploadedFile' is injected into this setter to trigger the update. If this |
874
|
|
|
* bundle's configuration parameter 'inject_on_load' is set to 'true' this setter |
875
|
|
|
* must be able to accept an instance of 'File' as the bundle will inject one here |
876
|
|
|
* during Doctrine hydration. |
877
|
|
|
* |
878
|
|
|
* @param File|\Symfony\Component\HttpFoundation\File\UploadedFile $image |
879
|
|
|
*/ |
880
|
|
|
public function setImage($image) |
881
|
|
|
{ |
882
|
|
|
$this->image = $image; |
883
|
|
|
|
884
|
|
|
if ($this->image) { |
885
|
|
|
$this->updatedAt = new \DateTime('now'); |
886
|
|
|
} |
887
|
|
|
} |
888
|
|
|
|
889
|
|
|
/** |
890
|
|
|
* @return File |
891
|
|
|
*/ |
892
|
|
|
public function getImage() |
893
|
|
|
{ |
894
|
|
|
return $this->image; |
895
|
|
|
} |
896
|
|
|
|
897
|
|
|
/** |
898
|
|
|
* @param string $imageName |
899
|
|
|
*/ |
900
|
|
|
public function setImageName($imageName) |
901
|
|
|
{ |
902
|
|
|
$this->imageName = $imageName; |
903
|
|
|
} |
904
|
|
|
|
905
|
|
|
/** |
906
|
|
|
* @return string |
907
|
|
|
*/ |
908
|
|
|
public function getImageName() |
909
|
|
|
{ |
910
|
|
|
return $this->imageName; |
911
|
|
|
} |
912
|
|
|
|
913
|
|
|
public function setProfilePictureUrl($profilePictureUrl) |
914
|
|
|
{ |
915
|
|
|
$this->profilePictureUrl = $profilePictureUrl; |
916
|
|
|
|
917
|
|
|
return $this; |
918
|
|
|
} |
919
|
|
|
|
920
|
|
|
public function getProfilePictureUrl() |
921
|
|
|
{ |
922
|
|
|
return $this->profilePictureUrl; |
923
|
|
|
} |
924
|
|
|
|
925
|
|
|
/** |
926
|
|
|
* @JMS\Groups({"public_profile"}) |
927
|
|
|
* @JMS\VirtualProperty |
928
|
|
|
* @JMS\SerializedName("age_range") |
929
|
|
|
* @JMS\Type("array") |
930
|
|
|
* @return array |
931
|
|
|
*/ |
932
|
|
|
public function getAgeRange() |
933
|
|
|
{ |
934
|
|
|
$today = new \DateTime('today'); |
935
|
|
|
if (!$this->getBirthdate()) { |
936
|
|
|
return array(); |
937
|
|
|
} |
938
|
|
|
$age = $this->getBirthdate()->diff($today)->y; |
939
|
|
|
|
940
|
|
|
$range = array(); |
941
|
|
|
if ($age < 13) { |
942
|
|
|
$range['max'] = 13; |
943
|
|
|
} |
944
|
|
|
if ($age >= 13 && $age < 18) { |
945
|
|
|
$range['min'] = 13; |
946
|
|
|
$range['max'] = 17; |
947
|
|
|
} |
948
|
|
|
if ($age >= 18 && $age < 21) { |
949
|
|
|
$range['min'] = 18; |
950
|
|
|
$range['max'] = 20; |
951
|
|
|
} |
952
|
|
|
if ($age >= 21) { |
953
|
|
|
$range['min'] = 21; |
954
|
|
|
} |
955
|
|
|
|
956
|
|
|
return $range; |
957
|
|
|
} |
958
|
|
|
|
959
|
|
|
public function getSuggestions() |
960
|
|
|
{ |
961
|
|
|
return $this->suggestions; |
962
|
|
|
} |
963
|
|
|
|
964
|
|
|
public function setSuggestions($suggestions) |
965
|
|
|
{ |
966
|
|
|
$this->suggestions = $suggestions; |
967
|
|
|
|
968
|
|
|
return $this; |
969
|
|
|
} |
970
|
|
|
|
971
|
|
|
public function isClientAuthorized($app_id) |
972
|
|
|
{ |
973
|
|
|
foreach ($this->getAuthorizations() as $auth) { |
974
|
|
|
if ($auth->getClient()->getPublicId() === $app_id) { |
975
|
|
|
return true; |
976
|
|
|
} |
977
|
|
|
} |
978
|
|
|
|
979
|
|
|
return false; |
980
|
|
|
} |
981
|
|
|
|
982
|
|
|
/** |
983
|
|
|
* @ORM\PreUpdate |
984
|
|
|
*/ |
985
|
1 |
|
public function setUpdatedAt($updatedAt = null) |
986
|
|
|
{ |
987
|
1 |
|
if ($updatedAt instanceof \DateTime) { |
988
|
1 |
|
$this->updatedAt = $updatedAt; |
989
|
|
|
} else { |
990
|
|
|
$this->updatedAt = new \DateTime('now'); |
991
|
|
|
} |
992
|
|
|
|
993
|
1 |
|
return $this; |
994
|
|
|
} |
995
|
|
|
|
996
|
1 |
|
public function getUpdatedAt() |
997
|
|
|
{ |
998
|
1 |
|
return $this->updatedAt; |
999
|
|
|
} |
1000
|
|
|
|
1001
|
|
|
public function setGoogleId($var) |
1002
|
|
|
{ |
1003
|
|
|
$this->googleId = $var; |
1004
|
|
|
|
1005
|
|
|
return $this; |
1006
|
|
|
} |
1007
|
|
|
|
1008
|
|
|
public function getGoogleId() |
1009
|
|
|
{ |
1010
|
|
|
return $this->googleId; |
1011
|
|
|
} |
1012
|
|
|
|
1013
|
|
|
public function setGoogleUsername($var) |
1014
|
|
|
{ |
1015
|
|
|
$this->googleUsername = $var; |
1016
|
|
|
|
1017
|
|
|
return $this; |
1018
|
|
|
} |
1019
|
|
|
|
1020
|
|
|
public function getGoogleUsername() |
1021
|
|
|
{ |
1022
|
|
|
return $this->googleUsername; |
1023
|
|
|
} |
1024
|
|
|
|
1025
|
|
|
public function setGoogleAccessToken($var) |
1026
|
|
|
{ |
1027
|
|
|
$this->googleAccessToken = $var; |
1028
|
|
|
|
1029
|
|
|
return $this; |
1030
|
|
|
} |
1031
|
|
|
|
1032
|
|
|
public function getGoogleAccessToken() |
1033
|
|
|
{ |
1034
|
|
|
return $this->googleAccessToken; |
1035
|
|
|
} |
1036
|
|
|
|
1037
|
1 |
|
public function setCountry(Country $country = null) |
1038
|
|
|
{ |
1039
|
1 |
|
$this->country = $country; |
1040
|
|
|
|
1041
|
1 |
|
return $this; |
1042
|
|
|
} |
1043
|
|
|
|
1044
|
2 |
|
public function getCountry() |
1045
|
|
|
{ |
1046
|
2 |
|
return $this->country; |
1047
|
|
|
} |
1048
|
|
|
|
1049
|
|
|
public function getIdCards() |
1050
|
|
|
{ |
1051
|
|
|
return $this->idCards; |
1052
|
|
|
} |
1053
|
|
|
|
1054
|
3 |
|
public function getBadges() |
1055
|
|
|
{ |
1056
|
|
|
$badges = /** @scrutinizer ignore-deprecated */ |
1057
|
3 |
|
$this->badges; |
1058
|
3 |
|
$badgesMap = []; |
1059
|
3 |
|
foreach ($badges as $badge) { |
1060
|
2 |
|
$key = "{$badge->getNamespace()}.{$badge->getName()}"; |
1061
|
2 |
|
$badgesMap[$key] = $badge; |
1062
|
|
|
} |
1063
|
|
|
|
1064
|
3 |
|
return $badgesMap; |
1065
|
|
|
} |
1066
|
|
|
|
1067
|
2 |
|
public function mergeBadges(array $badges) |
1068
|
|
|
{ |
1069
|
|
|
/** @scrutinizer ignore-deprecated */ |
1070
|
2 |
|
$this->badges = array_unique(array_merge($this->badges, $badges)); |
|
|
|
|
1071
|
|
|
|
1072
|
2 |
|
return $this; |
1073
|
|
|
} |
1074
|
|
|
|
1075
|
|
|
public function getFullNameOrUsername() |
1076
|
|
|
{ |
1077
|
|
|
if (null === $this->firstName) { |
1078
|
|
|
return $this->username; |
1079
|
|
|
} |
1080
|
|
|
|
1081
|
|
|
return $this->getFullName(); |
1082
|
|
|
} |
1083
|
|
|
|
1084
|
|
|
public function getLogoutKeys() |
1085
|
|
|
{ |
1086
|
|
|
return $this->logoutKeys; |
1087
|
|
|
} |
1088
|
|
|
|
1089
|
|
|
/** |
1090
|
|
|
* @return ArrayCollection |
1091
|
|
|
*/ |
1092
|
|
|
public function getAddresses() |
1093
|
|
|
{ |
1094
|
|
|
return $this->addresses; |
1095
|
|
|
} |
1096
|
|
|
|
1097
|
|
|
public function setLogoutKeys($logoutKeys) |
1098
|
|
|
{ |
1099
|
|
|
$this->logoutKeys = $logoutKeys; |
1100
|
|
|
|
1101
|
|
|
return $this; |
1102
|
|
|
} |
1103
|
|
|
|
1104
|
|
|
public function setAddresses($addresses) |
1105
|
|
|
{ |
1106
|
|
|
$this->addresses = $addresses; |
1107
|
|
|
|
1108
|
|
|
return $this; |
1109
|
|
|
} |
1110
|
|
|
|
1111
|
|
|
/** |
1112
|
|
|
* Checks whether 2FA is enabled. |
1113
|
|
|
* |
1114
|
|
|
* @return boolean |
1115
|
|
|
*/ |
1116
|
|
|
public function isTwoFactorAuthenticationEnabled() |
1117
|
|
|
{ |
1118
|
|
|
return $this->googleAuthenticatorSecret !== null; |
1119
|
|
|
} |
1120
|
|
|
|
1121
|
|
|
public function getGoogleAuthenticatorSecret() |
1122
|
|
|
{ |
1123
|
|
|
return $this->googleAuthenticatorSecret; |
1124
|
|
|
} |
1125
|
|
|
|
1126
|
|
|
public function setGoogleAuthenticatorSecret($googleAuthenticatorSecret) |
1127
|
|
|
{ |
1128
|
|
|
$this->googleAuthenticatorSecret = $googleAuthenticatorSecret; |
1129
|
|
|
|
1130
|
|
|
return $this; |
1131
|
|
|
} |
1132
|
|
|
|
1133
|
|
|
public function getBackupCodes() |
1134
|
|
|
{ |
1135
|
|
|
return $this->backupCodes; |
1136
|
|
|
} |
1137
|
|
|
|
1138
|
|
|
public function setBackupCodes(ArrayCollection $backupCodes) |
1139
|
|
|
{ |
1140
|
|
|
$this->backupCodes = $backupCodes; |
1141
|
|
|
|
1142
|
|
|
return $this; |
1143
|
|
|
} |
1144
|
|
|
|
1145
|
|
|
public function invalidateBackupCode($code) |
1146
|
|
|
{ |
1147
|
|
|
$backupCode = $this->findBackupCode($code); |
1148
|
|
|
$backupCode->setUsed(true); |
1149
|
|
|
|
1150
|
|
|
return $this; |
1151
|
|
|
} |
1152
|
|
|
|
1153
|
|
|
public function isBackupCode($code) |
1154
|
|
|
{ |
1155
|
|
|
$backupCode = $this->findBackupCode($code); |
1156
|
|
|
|
1157
|
|
|
return $backupCode !== false && $backupCode->getUsed() === false; |
1158
|
|
|
} |
1159
|
|
|
|
1160
|
|
|
/** |
1161
|
|
|
* @param string $code |
1162
|
|
|
* @return BackupCode|false |
1163
|
|
|
*/ |
1164
|
|
|
private function findBackupCode($code) |
1165
|
|
|
{ |
1166
|
|
|
$backupCodes = $this->getBackupCodes(); |
1167
|
|
|
foreach ($backupCodes as $backupCode) { |
1168
|
|
|
if ($backupCode->getCode() === $code) { |
1169
|
|
|
return $backupCode; |
1170
|
|
|
} |
1171
|
|
|
} |
1172
|
|
|
|
1173
|
|
|
return false; |
1174
|
|
|
} |
1175
|
|
|
|
1176
|
|
|
public function setNationality($var) |
1177
|
|
|
{ |
1178
|
|
|
$this->nationality = $var; |
1179
|
|
|
|
1180
|
|
|
return $this; |
1181
|
|
|
} |
1182
|
|
|
|
1183
|
|
|
public function getNationality() |
1184
|
|
|
{ |
1185
|
|
|
return $this->nationality; |
1186
|
|
|
} |
1187
|
|
|
|
1188
|
|
|
public function getPlaceOfBirth() |
1189
|
|
|
{ |
1190
|
|
|
$location = new LocationSelectData(); |
1191
|
|
|
$location->getFromObject($this); |
1192
|
|
|
|
1193
|
|
|
return $location; |
1194
|
|
|
} |
1195
|
|
|
|
1196
|
|
|
public function setPlaceOfBirth(LocationSelectData $location) |
1197
|
|
|
{ |
1198
|
|
|
$location->toObject($this); |
1199
|
|
|
} |
1200
|
|
|
|
1201
|
|
|
/** |
1202
|
|
|
* @JMS\Groups({"public_profile"}) |
1203
|
|
|
* @JMS\VirtualProperty |
1204
|
|
|
* @JMS\SerializedName("given_name") |
1205
|
|
|
* @JMS\Since("1.0") |
1206
|
|
|
*/ |
1207
|
|
|
public function getGivenName() |
1208
|
|
|
{ |
1209
|
|
|
return $this->getFirstName(); |
1210
|
|
|
} |
1211
|
|
|
|
1212
|
|
|
/** |
1213
|
|
|
* @JMS\Groups({"full_name","name"}) |
1214
|
|
|
* @JMS\VirtualProperty |
1215
|
|
|
* @JMS\SerializedName("family_name") |
1216
|
|
|
* @JMS\Since("1") |
1217
|
|
|
*/ |
1218
|
|
|
public function getFamilyName() |
1219
|
|
|
{ |
1220
|
|
|
return $this->getSurname(); |
1221
|
|
|
} |
1222
|
|
|
|
1223
|
|
|
/** |
1224
|
|
|
* @JMS\Groups({"mobile", "phone_number"}) |
1225
|
|
|
* @JMS\VirtualProperty |
1226
|
|
|
* @JMS\SerializedName("phone_number") |
1227
|
|
|
*/ |
1228
|
|
|
public function getPhoneNumber() |
1229
|
|
|
{ |
1230
|
|
|
return $this->getMobile(); |
1231
|
|
|
} |
1232
|
|
|
|
1233
|
|
|
/** |
1234
|
|
|
* @param bool $verified |
1235
|
|
|
* @return $this |
1236
|
|
|
*/ |
1237
|
1 |
|
public function setPhoneNumberVerified($verified = false) |
1238
|
|
|
{ |
1239
|
1 |
|
$this->phoneNumberVerified = $verified; |
1240
|
|
|
|
1241
|
1 |
|
return $this; |
1242
|
|
|
} |
1243
|
|
|
|
1244
|
|
|
/** |
1245
|
|
|
* @return bool |
1246
|
|
|
*/ |
1247
|
2 |
|
public function getPhoneNumberVerified() |
1248
|
|
|
{ |
1249
|
2 |
|
return $this->phoneNumberVerified; |
1250
|
|
|
} |
1251
|
|
|
|
1252
|
|
|
public function getPasswordEncoderName() |
1253
|
|
|
{ |
1254
|
|
|
return $this->passwordEncoderName; |
1255
|
|
|
} |
1256
|
|
|
|
1257
|
|
|
public function setPasswordEncoderName($passwordEncoderName) |
1258
|
|
|
{ |
1259
|
|
|
$this->passwordEncoderName = $passwordEncoderName; |
1260
|
|
|
|
1261
|
|
|
return $this; |
1262
|
|
|
} |
1263
|
|
|
|
1264
|
|
|
public function getEncoderName() |
1265
|
|
|
{ |
1266
|
|
|
$encoder = $this->passwordEncoderName; |
1267
|
|
|
|
1268
|
|
|
// BC for PR #357 |
1269
|
|
|
if ($encoder === null || strlen($encoder) < 1) { |
1270
|
|
|
return null; |
1271
|
|
|
} |
1272
|
|
|
|
1273
|
|
|
return $encoder; |
1274
|
|
|
} |
1275
|
|
|
|
1276
|
|
|
public function getLongDisplayName() |
1277
|
|
|
{ |
1278
|
|
|
if ($this->getFullName()) { |
1279
|
|
|
return $this->getFullName(); |
1280
|
|
|
} else { |
1281
|
|
|
return $this->getEmail(); |
1282
|
|
|
} |
1283
|
|
|
} |
1284
|
|
|
|
1285
|
|
|
public function getShortDisplayName() |
1286
|
|
|
{ |
1287
|
|
|
if ($this->getGivenName()) { |
1288
|
|
|
return $this->getGivenName(); |
1289
|
|
|
} else { |
1290
|
|
|
return $this->getEmail(); |
1291
|
|
|
} |
1292
|
|
|
} |
1293
|
|
|
} |
1294
|
|
|
|