Completed
Push — master ( 3fdc35...16364b )
by Julito
13:14
created

User::hasExtraFieldByName()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 4
nc 3
nop 1
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
1
<?php
2
/* For licensing terms, see /license.txt */
3
4
namespace Chamilo\UserBundle\Entity;
5
6
//use Chamilo\CoreBundle\Entity\UserFieldValues;
7
use Chamilo\CoreBundle\Entity\AccessUrl;
8
use Chamilo\CoreBundle\Entity\AccessUrlRelUser;
9
use Chamilo\CoreBundle\Entity\ExtraFieldValues;
10
use Chamilo\CoreBundle\Entity\Skill;
11
use Chamilo\CoreBundle\Entity\UsergroupRelUser;
12
use Chamilo\ThemeBundle\Model\UserInterface as ThemeUser;
13
use Doctrine\Common\Collections\ArrayCollection;
14
use Doctrine\ORM\Event\LifecycleEventArgs;
15
use Doctrine\ORM\Mapping as ORM;
16
use FOS\UserBundle\Model\GroupInterface;
17
18
use Symfony\Component\Security\Core\User\UserInterface;
19
use Sonata\UserBundle\Entity\BaseUser;
20
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
21
use Symfony\Component\HttpFoundation\File\File;
22
use Symfony\Component\Security\Core\User\EquatableInterface;
23
use Symfony\Component\Validator\Constraints as Assert;
24
use Symfony\Component\Validator\Mapping\ClassMetadata;
25
26
//use Chamilo\CoreBundle\Component\Auth;
27
//use FOS\MessageBundle\Model\ParticipantInterface;
28
//use Chamilo\ThemeBundle\Model\UserInterface as ThemeUser;
29
//use Vich\UploaderBundle\Mapping\Annotation as Vich;
30
//use Application\Sonata\MediaBundle\Entity\Media;
31
//use Chamilo\UserBundle\Model\UserInterface as UserInterfaceModel;
32
//use Sylius\Component\Attribute\Model\AttributeValueInterface as BaseAttributeValueInterface;
33
//use Sylius\Component\Variation\Model\OptionInterface as BaseOptionInterface;
34
//use Sylius\Component\Variation\Model\VariantInterface as BaseVariantInterface;
35
36
/**
37
 * @ORM\HasLifecycleCallbacks
38
 * @ORM\Table(
39
 *  name="user",
40
 *  indexes={
41
 *      @ORM\Index(name="idx_user_uid", columns={"user_id"}),
42
 *      @ORM\Index(name="status", columns={"status"})
43
 *  }
44
 * )
45
 * @UniqueEntity("username")
46
 * @ORM\Entity(repositoryClass="Chamilo\UserBundle\Entity\Repository\UserRepository")
47
 *
48
 * @ORM\AttributeOverrides({
49
 *     @ORM\AttributeOverride(name="username",
50
 *         column=@ORM\Column(
51
 *             name="username",
52
 *             type="string",
53
 *             length=100,
54
 *             unique=true
55
 *         )
56
 *     ),
57
 *      @ORM\AttributeOverride(name="email",
58
 *         column=@ORM\Column(
59
 *             name="email",
60
 *             type="string",
61
 *             length=100,
62
 *             unique=false
63
 *         )
64
 *     ),
65
 *     @ORM\AttributeOverride(name="emailCanonical",
66
 *         column=@ORM\Column(
67
 *             name="email_canonical",
68
 *             type="string",
69
 *             length=100,
70
 *             unique=false
71
 *         )
72
 *     ),
73
 *     @ORM\AttributeOverride(name="usernameCanonical",
74
 *         column=@ORM\Column(
75
 *             name="username_canonical",
76
 *             type="string",
77
 *             length=180,
78
 *             unique=false
79
 *         )
80
 *     )
81
 * })
82
 */
83
class User extends BaseUser implements ThemeUser, EquatableInterface //implements ParticipantInterface, ThemeUser
84
{
85
    const COURSE_MANAGER = 1;
86
    const TEACHER = 1;
87
    const SESSION_ADMIN = 3;
88
    const DRH = 4;
89
    const STUDENT = 5;
90
    const ANONYMOUS = 6;
91
92
    /**
93
     * @var int
94
     *
95
     * @ORM\Column(name="id", type="integer")
96
     * @ORM\Id
97
     * @ORM\GeneratedValue(strategy="AUTO")
98
     */
99
    protected $id;
100
101
    /**
102
     * @var int
103
     *
104
     * @ORM\Column(name="user_id", type="integer", nullable=true)
105
     */
106
    protected $userId;
107
108
    /**
109
     * @var string
110
     *
111
     * @ORM\Column(name="username", type="string", length=100, nullable=false, unique=true)
112
     */
113
    //protected $username;
114
115
    /**
116
     * @var string
117
     *
118
     * @ORM\Column(name="username_canonical", type="string", length=100, nullable=false)
119
     */
120
    //protected $usernameCanonical;
121
122
    /**
123
     * @var string
124
     * @ORM\Column(name="email_canonical", type="string", length=100, nullable=false, unique=false)
125
     */
126
    //protected $emailCanonical;
127
128
    /**
129
     * @var string
130
     *
131
     * @ORM\Column(name="email", type="string", length=100, nullable=false, unique=false)
132
     */
133
    //protected $email;
134
135
    /**
136
     * @var bool
137
     * @ORM\Column(name="locked", type="boolean")
138
     */
139
    protected $locked;
140
141
    /**
142
     * @var bool
143
     * @ORM\Column(name="enabled", type="boolean")
144
     */
145
    //protected $enabled;
146
147
    /**
148
     * @var bool
149
     * @ORM\Column(name="expired", type="boolean")
150
     */
151
    protected $expired;
152
153
    /**
154
     * @var bool
155
     * @ORM\Column(name="credentials_expired", type="boolean")
156
     */
157
    protected $credentialsExpired;
158
159
    /**
160
     * @var \DateTime
161
     * @ORM\Column(name="credentials_expire_at", type="datetime", nullable=true, unique=false)
162
     */
163
    protected $credentialsExpireAt;
164
165
    /**
166
     * @var \DateTime
167
     * @ORM\Column(name="expires_at", type="datetime", nullable=true, unique=false)
168
     */
169
    protected $expiresAt;
170
171
    /**
172
     * @var string
173
     *
174
     * @ORM\Column(name="phone", type="string", length=30, nullable=true, unique=false)
175
     */
176
    //protected $phone;
177
178
    /**
179
     * @var string
180
     *
181
     * @ORM\Column(name="address", type="string", length=250, nullable=true, unique=false)
182
     */
183
    protected $address;
184
185
    /**
186
     * Vich\UploadableField(mapping="user_image", fileNameProperty="picture_uri").
187
     *
188
     * note This is not a mapped field of entity metadata, just a simple property.
189
     *
190
     * @var File
191
     */
192
    protected $imageFile;
193
194
    /**
195
     * @var AccessUrl
196
     */
197
    protected $currentUrl;
198
199
    /**
200
     * @ORM\Column(type="string", length=255)
201
     */
202
    //protected $salt;
203
204
    /**
205
     * @var \DateTime
206
     *
207
     * @ORM\Column(name="last_login", type="datetime", nullable=true, unique=false)
208
     */
209
    //protected $lastLogin;
210
211
    /**
212
     * @var \DateTime
213
     * @ORM\Column(name="created_at", type="datetime", nullable=true, unique=false)
214
     */
215
    //protected $createdAt;
216
217
    /**
218
     * @var \DateTime
219
     * @ORM\Column(name="updated_at", type="datetime", nullable=true, unique=false)
220
     */
221
    //protected $updatedAt;
222
223
    /**
224
     * Random string sent to the user email address in order to verify it.
225
     *
226
     * @var string
227
     * @ORM\Column(name="confirmation_token", type="string", length=255, nullable=true)
228
     */
229
    //protected $confirmationToken;
230
231
    /**
232
     * @var \DateTime
233
     *
234
     * @ORM\Column(name="password_requested_at", type="datetime", nullable=true, unique=false)
235
     */
236
    //protected $passwordRequestedAt;
237
238
    /**
239
     * @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\CourseRelUser", mappedBy="user")
240
     */
241
    protected $courses;
242
243
    /**
244
     * @ORM\OneToMany(targetEntity="Chamilo\CourseBundle\Entity\CItemProperty", mappedBy="user")
245
     */
246
    //protected $items;
247
248
    /**
249
     * @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\UsergroupRelUser", mappedBy="user")
250
     */
251
    protected $classes;
252
253
    /**
254
     * ORM\OneToMany(targetEntity="Chamilo\CourseBundle\Entity\CDropboxPost", mappedBy="user").
255
     */
256
    protected $dropBoxReceivedFiles;
257
258
    /**
259
     * ORM\OneToMany(targetEntity="Chamilo\CourseBundle\Entity\CDropboxFile", mappedBy="userSent").
260
     */
261
    protected $dropBoxSentFiles;
262
263
    /**
264
     * @ORM\Column(type="array")
265
     */
266
    //protected $roles;
267
268
    /**
269
     * @var bool
270
     *
271
     * @ORM\Column(name="profile_completed", type="boolean", nullable=true)
272
     */
273
    protected $profileCompleted;
274
275
    /**
276
     * @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\JuryMembers", mappedBy="user")
277
     */
278
    //protected $jurySubscriptions;
279
280
    /**
281
     * @ORM\ManyToMany(targetEntity="Chamilo\UserBundle\Entity\Group")
282
     * @ORM\JoinTable(name="fos_user_user_group",
283
     *      joinColumns={@ORM\JoinColumn(name="user_id", referencedColumnName="id")},
284
     *      inverseJoinColumns={@ORM\JoinColumn(name="group_id", referencedColumnName="id")}
285
     * )
286
     */
287
    protected $groups;
288
289
    //private $isActive;
290
291
    /**
292
     * ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\CurriculumItemRelUser", mappedBy="user").
293
     */
294
    protected $curriculumItems;
295
296
    /*
297
     * @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\AccessUrlRelUser", mappedBy="user")
298
     *
299
     */
300
    protected $portals;
301
302
    /**
303
     * @var ArrayCollection
304
     * @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\Session", mappedBy="generalCoach")
305
     */
306
    protected $sessionAsGeneralCoach;
307
308
    /**
309
     * @var ArrayCollection
310
     *                      ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\UserFieldValues", mappedBy="user", orphanRemoval=true, cascade={"persist"})
311
     */
312
    protected $extraFields;
313
314
    /**
315
     * ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\Resource\ResourceNode", mappedBy="creator").
316
     */
317
    protected $resourceNodes;
318
319
    /**
320
     * @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\SessionRelCourseRelUser", mappedBy="user", cascade={"persist"})
321
     */
322
    protected $sessionCourseSubscriptions;
323
324
    /**
325
     * @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\SkillRelUser", mappedBy="user", cascade={"persist"})
326
     */
327
    protected $achievedSkills;
328
329
    /**
330
     * @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\SkillRelUserComment", mappedBy="feedbackGiver")
331
     */
332
    protected $commentedUserSkills;
333
334
    /**
335
     * @var string
336
     *
337
     * @ORM\Column(name="auth_source", type="string", length=50, nullable=true, unique=false)
338
     */
339
    private $authSource;
340
341
    /**
342
     * @var int
343
     *
344
     * @ORM\Column(name="status", type="integer", nullable=false)
345
     */
346
    private $status;
347
348
    /**
349
     * @var string
350
     *
351
     * @ORM\Column(name="official_code", type="string", length=40, nullable=true, unique=false)
352
     */
353
    private $officialCode;
354
355
    /**
356
     * @var string
357
     * @ORM\Column(name="picture_uri", type="string", length=250, nullable=true, unique=false)
358
     */
359
    private $pictureUri;
360
361
    /**
362
     * @var int
363
     *
364
     * @ORM\Column(name="creator_id", type="integer", nullable=true, unique=false)
365
     */
366
    private $creatorId;
367
368
    /**
369
     * @var string
370
     *
371
     * @ORM\Column(name="competences", type="text", nullable=true, unique=false)
372
     */
373
    private $competences;
374
375
    /**
376
     * @var string
377
     *
378
     * @ORM\Column(name="diplomas", type="text", nullable=true, unique=false)
379
     */
380
    private $diplomas;
381
382
    /**
383
     * @var string
384
     *
385
     * @ORM\Column(name="openarea", type="text", nullable=true, unique=false)
386
     */
387
    private $openarea;
388
389
    /**
390
     * @var string
391
     *
392
     * @ORM\Column(name="teach", type="text", nullable=true, unique=false)
393
     */
394
    private $teach;
395
396
    /**
397
     * @var string
398
     *
399
     * @ORM\Column(name="productions", type="string", length=250, nullable=true, unique=false)
400
     */
401
    private $productions;
402
403
    /**
404
     * @var string
405
     *
406
     * @ORM\Column(name="language", type="string", length=40, nullable=true, unique=false)
407
     */
408
    private $language;
409
410
    /**
411
     * @var \DateTime
412
     *
413
     * @ORM\Column(name="registration_date", type="datetime", nullable=false, unique=false)
414
     */
415
    private $registrationDate;
416
417
    /**
418
     * @var \DateTime
419
     *
420
     * @ORM\Column(name="expiration_date", type="datetime", nullable=true, unique=false)
421
     */
422
    private $expirationDate;
423
424
    /**
425
     * @var bool
426
     *
427
     * @ORM\Column(name="active", type="boolean", nullable=false, unique=false)
428
     */
429
    private $active;
430
431
    /**
432
     * @var string
433
     *
434
     * @ORM\Column(name="openid", type="string", length=255, nullable=true, unique=false)
435
     */
436
    private $openid;
437
438
    /**
439
     * @var string
440
     *
441
     * @ORM\Column(name="theme", type="string", length=255, nullable=true, unique=false)
442
     */
443
    private $theme;
444
445
    /**
446
     * @var int
447
     *
448
     * @ORM\Column(name="hr_dept_id", type="smallint", nullable=true, unique=false)
449
     */
450
    private $hrDeptId;
451
452
    /**
453
     * Constructor.
454
     */
455
    public function __construct()
456
    {
457
        parent::__construct();
458
        $this->status = self::STUDENT;
459
        $this->salt = sha1(uniqid(null, true));
0 ignored issues
show
Bug Best Practice introduced by
The property salt does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
460
        $this->active = true;
461
        $this->registrationDate = new \DateTime();
462
        $this->authSource = 'platform';
463
        $this->courses = new ArrayCollection();
464
        //$this->items = new ArrayCollection();
465
        $this->classes = new ArrayCollection();
466
        $this->curriculumItems = new ArrayCollection();
467
        $this->portals = new ArrayCollection();
468
        $this->dropBoxSentFiles = new ArrayCollection();
469
        $this->dropBoxReceivedFiles = new ArrayCollection();
470
        //$this->extraFields = new ArrayCollection();
471
        //$this->userId = 0;
472
        //$this->createdAt = new \DateTime();
473
        //$this->updatedAt = new \DateTime();
474
475
        $this->enabled = false;
0 ignored issues
show
Bug Best Practice introduced by
The property enabled does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
476
        $this->locked = false;
477
        $this->expired = false;
478
        $this->roles = [];
0 ignored issues
show
Bug Best Practice introduced by
The property roles does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
479
        $this->credentialsExpired = false;
480
    }
481
482
    /**
483
     * @return string
484
     */
485
    public function __toString()
486
    {
487
        return $this->getCompleteName();
488
    }
489
490
    /**
491
     * Updates the id with the user_id.
492
     *
493
     * @ORM\PostPersist()
494
     *
495
     * @param LifecycleEventArgs $args
496
     */
497
    public function postPersist(LifecycleEventArgs $args)
498
    {
499
        $user = $args->getEntity();
500
        $this->setUserId($user->getId());
501
    }
502
503
    /**
504
     * @param int $userId
505
     */
506
    public function setId($userId)
507
    {
508
        $this->id = $userId;
509
    }
510
511
    /**
512
     * @param int $userId
513
     */
514
    public function setUserId($userId)
515
    {
516
        if (!empty($userId)) {
517
            $this->userId = $userId;
518
        }
519
    }
520
521
    /**
522
     * @return int
523
     */
524
    public function getId()
525
    {
526
        return $this->id;
527
    }
528
529
    /**
530
     * @return ArrayCollection
531
     */
532
    public function getDropBoxSentFiles()
533
    {
534
        return $this->dropBoxSentFiles;
535
    }
536
537
    /**
538
     * @return ArrayCollection
539
     */
540
    public function getDropBoxReceivedFiles()
541
    {
542
        return $this->dropBoxReceivedFiles;
543
    }
544
545
    /**
546
     * @return ArrayCollection
547
     */
548
    public function getCourses()
549
    {
550
        return $this->courses;
551
    }
552
553
    /**
554
     * @return array
555
     */
556
    public static function getPasswordConstraints()
557
    {
558
        return
559
            [
560
                new Assert\Length(['min' => 5]),
561
                // Alpha numeric + "_" or "-"
562
                new Assert\Regex(
563
                    [
564
                        'pattern' => '/^[a-z\-_0-9]+$/i',
565
                        'htmlPattern' => '/^[a-z\-_0-9]+$/i', ]
566
                ),
567
                // Min 3 letters - not needed
568
                /*new Assert\Regex(array(
569
                    'pattern' => '/[a-z]{3}/i',
570
                    'htmlPattern' => '/[a-z]{3}/i')
571
                ),*/
572
                // Min 2 numbers
573
                new Assert\Regex(
574
                    [
575
                        'pattern' => '/[0-9]{2}/',
576
                        'htmlPattern' => '/[0-9]{2}/', ]
577
                ),
578
            ]
579
            ;
580
    }
581
582
    /**
583
     * @param ClassMetadata $metadata
584
     */
585
    public static function loadValidatorMetadata(ClassMetadata $metadata)
586
    {
587
        //$metadata->addPropertyConstraint('firstname', new Assert\NotBlank());
588
        //$metadata->addPropertyConstraint('lastname', new Assert\NotBlank());
589
        //$metadata->addPropertyConstraint('email', new Assert\Email());
590
        /*
591
        $metadata->addPropertyConstraint('password',
592
            new Assert\Collection(self::getPasswordConstraints())
593
        );*/
594
595
        /*$metadata->addConstraint(new UniqueEntity(array(
596
            'fields'  => 'username',
597
            'message' => 'This value is already used.',
598
        )));*/
599
600
        /*$metadata->addPropertyConstraint(
601
            'username',
602
            new Assert\Length(array(
603
                'min'        => 2,
604
                'max'        => 50,
605
                'minMessage' => 'This value is too short. It should have {{ limit }} character or more.|This value is too short. It should have {{ limit }} characters or more.',
606
                'maxMessage' => 'This value is too long. It should have {{ limit }} character or less.|This value is too long. It should have {{ limit }} characters or less.',
607
            ))
608
        );*/
609
    }
610
611
    /**
612
     * @return ArrayCollection
613
     */
614
    public function getPortals()
615
    {
616
        return $this->portals;
617
    }
618
619
    /**
620
     * @param $portal
621
     */
622
    public function setPortal($portal)
623
    {
624
        $this->portals->add($portal);
625
    }
626
627
    /**
628
     * @return ArrayCollection
629
     */
630
    public function getCurriculumItems()
631
    {
632
        return $this->curriculumItems;
633
    }
634
635
    /**
636
     * @param $items
637
     */
638
    public function setCurriculumItems($items)
639
    {
640
        $this->curriculumItems = $items;
641
    }
642
643
    /**
644
     * @return bool
645
     */
646
    public function getIsActive()
647
    {
648
        return $this->active == 1;
649
    }
650
651
    /**
652
     * @return bool
653
     */
654
    public function isActive()
655
    {
656
        return $this->getIsActive();
657
    }
658
659
    /**
660
     * {@inheritdoc}
661
     */
662
    public function isEnabled()
663
    {
664
        return $this->getActive() == 1;
665
    }
666
667
    /**
668
     * @return ArrayCollection
669
     */
670
    /*public function getRolesObj()
671
    {
672
        return $this->roles;
673
    }*/
674
675
    /**
676
     * Set salt.
677
     *
678
     * @param string $salt
679
     *
680
     * @return User
681
     */
682
    public function setSalt($salt)
683
    {
684
        $this->salt = $salt;
0 ignored issues
show
Bug Best Practice introduced by
The property salt does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
685
686
        return $this;
687
    }
688
689
    /**
690
     * Get salt.
691
     *
692
     * @return string
693
     */
694
    public function getSalt()
695
    {
696
        return $this->salt;
697
    }
698
699
    /**
700
     * @return ArrayCollection
701
     */
702
    public function getClasses()
703
    {
704
        return $this->classes;
705
    }
706
707
    public function getLps()
708
    {
709
        //return $this->lps;
710
        /*$criteria = Criteria::create()
711
            ->where(Criteria::expr()->eq("id", "666"))
712
            //->orderBy(array("username" => "ASC"))
713
            //->setFirstResult(0)
714
            //->setMaxResults(20)
715
        ;
716
        $lps = $this->lps->matching($criteria);*/
717
        /*return $this->lps->filter(
718
            function($entry) use ($idsToFilter) {
719
                return $entry->getId() == 1;
720
        });*/
721
    }
722
723
    /**
724
     * Return Complete Name with the Username.
725
     *
726
     * @return string
727
     */
728
    public function getCompleteNameWithUsername()
729
    {
730
        return api_get_person_name($this->firstname, $this->lastname).' ('.$this->username.')';
731
    }
732
733
    /**
734
     * @todo don't use api_get_person_name
735
     *
736
     * @return string
737
     */
738
    public function getCompleteName()
739
    {
740
        return api_get_person_name($this->firstname, $this->lastname);
741
    }
742
743
    /**
744
     * Returns the list of classes for the user.
745
     *
746
     * @return string
747
     */
748
    public function getCompleteNameWithClasses()
749
    {
750
        $classSubscription = $this->getClasses();
751
        $classList = [];
752
        /** @var UsergroupRelUser $subscription */
753
        foreach ($classSubscription as $subscription) {
754
            $class = $subscription->getUsergroup();
755
            $classList[] = $class->getName();
756
        }
757
        $classString = !empty($classList) ? ' ['.implode(', ', $classList).']' : null;
758
759
        return $this->getCompleteName().$classString;
760
    }
761
762
    /**
763
     * Get userId.
764
     *
765
     * @return int
766
     */
767
    public function getUserId()
768
    {
769
        return $this->userId;
770
    }
771
772
    /**
773
     * Set lastname.
774
     *
775
     * @param string $lastname
776
     *
777
     * @return User
778
     */
779
    public function setLastname($lastname)
780
    {
781
        $this->lastname = $lastname;
0 ignored issues
show
Bug Best Practice introduced by
The property lastname does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
782
783
        return $this;
784
    }
785
786
    /**
787
     * Set firstname.
788
     *
789
     * @param string $firstname
790
     *
791
     * @return User
792
     */
793
    public function setFirstname($firstname)
794
    {
795
        $this->firstname = $firstname;
0 ignored issues
show
Bug Best Practice introduced by
The property firstname does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
796
797
        return $this;
798
    }
799
800
    /**
801
     * Set password.
802
     *
803
     * @param string $password
804
     *
805
     * @return User
806
     */
807
    public function setPassword($password)
808
    {
809
        $this->password = $password;
0 ignored issues
show
Bug Best Practice introduced by
The property password does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
810
811
        return $this;
812
    }
813
814
    /**
815
     * Get password.
816
     *
817
     * @return string
818
     */
819
    public function getPassword()
820
    {
821
        return $this->password;
822
    }
823
824
    /**
825
     * Set authSource.
826
     *
827
     * @param string $authSource
828
     *
829
     * @return User
830
     */
831
    public function setAuthSource($authSource)
832
    {
833
        $this->authSource = $authSource;
834
835
        return $this;
836
    }
837
838
    /**
839
     * Get authSource.
840
     *
841
     * @return string
842
     */
843
    public function getAuthSource()
844
    {
845
        return $this->authSource;
846
    }
847
848
    /**
849
     * Set email.
850
     *
851
     * @param string $email
852
     *
853
     * @return User
854
     */
855
    public function setEmail($email)
856
    {
857
        $this->email = $email;
0 ignored issues
show
Bug Best Practice introduced by
The property email does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
858
859
        return $this;
860
    }
861
862
    /**
863
     * Get email.
864
     *
865
     * @return string
866
     */
867
    public function getEmail()
868
    {
869
        return $this->email;
870
    }
871
872
    /**
873
     * Set status.
874
     *
875
     * @param int $status
876
     *
877
     * @return User
878
     */
879
    public function setStatus($status)
880
    {
881
        $this->status = $status;
882
883
        return $this;
884
    }
885
886
    /**
887
     * Get status.
888
     *
889
     * @return int
890
     */
891
    public function getStatus()
892
    {
893
        return $this->status;
894
    }
895
896
    /**
897
     * Set officialCode.
898
     *
899
     * @param string $officialCode
900
     *
901
     * @return User
902
     */
903
    public function setOfficialCode($officialCode)
904
    {
905
        $this->officialCode = $officialCode;
906
907
        return $this;
908
    }
909
910
    /**
911
     * Get officialCode.
912
     *
913
     * @return string
914
     */
915
    public function getOfficialCode()
916
    {
917
        return $this->officialCode;
918
    }
919
920
    /**
921
     * Set phone.
922
     *
923
     * @param string $phone
924
     *
925
     * @return User
926
     */
927
    public function setPhone($phone)
928
    {
929
        $this->phone = $phone;
0 ignored issues
show
Bug Best Practice introduced by
The property phone does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
930
931
        return $this;
932
    }
933
934
    /**
935
     * Get phone.
936
     *
937
     * @return string
938
     */
939
    public function getPhone()
940
    {
941
        return $this->phone;
942
    }
943
944
    /**
945
     * Set address.
946
     *
947
     * @param string $address
948
     *
949
     * @return User
950
     */
951
    public function setAddress($address)
952
    {
953
        $this->address = $address;
954
955
        return $this;
956
    }
957
958
    /**
959
     * Get address.
960
     *
961
     * @return string
962
     */
963
    public function getAddress()
964
    {
965
        return $this->address;
966
    }
967
968
    /**
969
     * Set pictureUri.
970
     *
971
     * @param string $pictureUri
972
     *
973
     * @return User
974
     */
975
    public function setPictureUri($pictureUri)
976
    {
977
        $this->pictureUri = $pictureUri;
978
979
        return $this;
980
    }
981
982
    /**
983
     * Get pictureUri.
984
     *
985
     * @return Media
986
     */
987
    public function getPictureUri()
988
    {
989
        return $this->pictureUri;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->pictureUri returns the type string which is incompatible with the documented return type Chamilo\UserBundle\Entity\Media.
Loading history...
990
    }
991
992
    /**
993
     * Set creatorId.
994
     *
995
     * @param int $creatorId
996
     *
997
     * @return User
998
     */
999
    public function setCreatorId($creatorId)
1000
    {
1001
        $this->creatorId = $creatorId;
1002
1003
        return $this;
1004
    }
1005
1006
    /**
1007
     * Get creatorId.
1008
     *
1009
     * @return int
1010
     */
1011
    public function getCreatorId()
1012
    {
1013
        return $this->creatorId;
1014
    }
1015
1016
    /**
1017
     * Set competences.
1018
     *
1019
     * @param string $competences
1020
     *
1021
     * @return User
1022
     */
1023
    public function setCompetences($competences)
1024
    {
1025
        $this->competences = $competences;
1026
1027
        return $this;
1028
    }
1029
1030
    /**
1031
     * Get competences.
1032
     *
1033
     * @return string
1034
     */
1035
    public function getCompetences()
1036
    {
1037
        return $this->competences;
1038
    }
1039
1040
    /**
1041
     * Set diplomas.
1042
     *
1043
     * @param string $diplomas
1044
     *
1045
     * @return User
1046
     */
1047
    public function setDiplomas($diplomas)
1048
    {
1049
        $this->diplomas = $diplomas;
1050
1051
        return $this;
1052
    }
1053
1054
    /**
1055
     * Get diplomas.
1056
     *
1057
     * @return string
1058
     */
1059
    public function getDiplomas()
1060
    {
1061
        return $this->diplomas;
1062
    }
1063
1064
    /**
1065
     * Set openarea.
1066
     *
1067
     * @param string $openarea
1068
     *
1069
     * @return User
1070
     */
1071
    public function setOpenarea($openarea)
1072
    {
1073
        $this->openarea = $openarea;
1074
1075
        return $this;
1076
    }
1077
1078
    /**
1079
     * Get openarea.
1080
     *
1081
     * @return string
1082
     */
1083
    public function getOpenarea()
1084
    {
1085
        return $this->openarea;
1086
    }
1087
1088
    /**
1089
     * Set teach.
1090
     *
1091
     * @param string $teach
1092
     *
1093
     * @return User
1094
     */
1095
    public function setTeach($teach)
1096
    {
1097
        $this->teach = $teach;
1098
1099
        return $this;
1100
    }
1101
1102
    /**
1103
     * Get teach.
1104
     *
1105
     * @return string
1106
     */
1107
    public function getTeach()
1108
    {
1109
        return $this->teach;
1110
    }
1111
1112
    /**
1113
     * Set productions.
1114
     *
1115
     * @param string $productions
1116
     *
1117
     * @return User
1118
     */
1119
    public function setProductions($productions)
1120
    {
1121
        $this->productions = $productions;
1122
1123
        return $this;
1124
    }
1125
1126
    /**
1127
     * Get productions.
1128
     *
1129
     * @return string
1130
     */
1131
    public function getProductions()
1132
    {
1133
        return $this->productions;
1134
    }
1135
1136
    /**
1137
     * Set language.
1138
     *
1139
     * @param string $language
1140
     *
1141
     * @return User
1142
     */
1143
    public function setLanguage($language)
1144
    {
1145
        $this->language = $language;
1146
1147
        return $this;
1148
    }
1149
1150
    /**
1151
     * Get language.
1152
     *
1153
     * @return string
1154
     */
1155
    public function getLanguage()
1156
    {
1157
        return $this->language;
1158
    }
1159
1160
    /**
1161
     * Set registrationDate.
1162
     *
1163
     * @param \DateTime $registrationDate
1164
     *
1165
     * @return User
1166
     */
1167
    public function setRegistrationDate($registrationDate)
1168
    {
1169
        $this->registrationDate = $registrationDate;
1170
1171
        return $this;
1172
    }
1173
1174
    /**
1175
     * Get registrationDate.
1176
     *
1177
     * @return \DateTime
1178
     */
1179
    public function getRegistrationDate()
1180
    {
1181
        return $this->registrationDate;
1182
    }
1183
1184
    /**
1185
     * Set expirationDate.
1186
     *
1187
     * @param \DateTime $expirationDate
1188
     *
1189
     * @return User
1190
     */
1191
    public function setExpirationDate($expirationDate)
1192
    {
1193
        $this->expirationDate = $expirationDate;
1194
1195
        return $this;
1196
    }
1197
1198
    /**
1199
     * Get expirationDate.
1200
     *
1201
     * @return \DateTime
1202
     */
1203
    public function getExpirationDate()
1204
    {
1205
        return $this->expirationDate;
1206
    }
1207
1208
    /**
1209
     * Set active.
1210
     *
1211
     * @param bool $active
1212
     *
1213
     * @return User
1214
     */
1215
    public function setActive($active)
1216
    {
1217
        $this->active = $active;
1218
1219
        return $this;
1220
    }
1221
1222
    /**
1223
     * Get active.
1224
     *
1225
     * @return bool
1226
     */
1227
    public function getActive()
1228
    {
1229
        return $this->active;
1230
    }
1231
1232
    /**
1233
     * Set openid.
1234
     *
1235
     * @param string $openid
1236
     *
1237
     * @return User
1238
     */
1239
    public function setOpenid($openid)
1240
    {
1241
        $this->openid = $openid;
1242
1243
        return $this;
1244
    }
1245
1246
    /**
1247
     * Get openid.
1248
     *
1249
     * @return string
1250
     */
1251
    public function getOpenid()
1252
    {
1253
        return $this->openid;
1254
    }
1255
1256
    /**
1257
     * Set theme.
1258
     *
1259
     * @param string $theme
1260
     *
1261
     * @return User
1262
     */
1263
    public function setTheme($theme)
1264
    {
1265
        $this->theme = $theme;
1266
1267
        return $this;
1268
    }
1269
1270
    /**
1271
     * Get theme.
1272
     *
1273
     * @return string
1274
     */
1275
    public function getTheme()
1276
    {
1277
        return $this->theme;
1278
    }
1279
1280
    /**
1281
     * Set hrDeptId.
1282
     *
1283
     * @param int $hrDeptId
1284
     *
1285
     * @return User
1286
     */
1287
    public function setHrDeptId($hrDeptId)
1288
    {
1289
        $this->hrDeptId = $hrDeptId;
1290
1291
        return $this;
1292
    }
1293
1294
    /**
1295
     * Get hrDeptId.
1296
     *
1297
     * @return int
1298
     */
1299
    public function getHrDeptId()
1300
    {
1301
        return $this->hrDeptId;
1302
    }
1303
1304
    /**
1305
     * @return Media
1306
     */
1307
    public function getAvatar()
1308
    {
1309
        return $this->getPictureUri();
1310
    }
1311
1312
    /**
1313
     * @param int $size
1314
     *
1315
     * @return string
1316
     */
1317
    public function getAvatarOrAnonymous($size = 22)
1318
    {
1319
        $avatar = $this->getAvatar();
1320
1321
        if (empty($avatar)) {
1322
            return "img/icons/$size/unknown.png";
1323
        }
1324
1325
        return $avatar;
1326
    }
1327
1328
    /**
1329
     * @return \DateTime
1330
     */
1331
    public function getMemberSince()
1332
    {
1333
        return $this->registrationDate;
1334
    }
1335
1336
    /**
1337
     * @return bool
1338
     */
1339
    public function isOnline()
1340
    {
1341
        return false;
1342
    }
1343
1344
    /**
1345
     * @return int
1346
     */
1347
    public function getIdentifier()
1348
    {
1349
        return $this->getId();
1350
    }
1351
1352
    /**
1353
     * If manually uploading a file (i.e. not using Symfony Form) ensure an instance
1354
     * of 'UploadedFile' is injected into this setter to trigger the  update. If this
1355
     * bundle's configuration parameter 'inject_on_load' is set to 'true' this setter
1356
     * must be able to accept an instance of 'File' as the bundle will inject one here
1357
     * during Doctrine hydration.
1358
     *
1359
     * @param File|\Symfony\Component\HttpFoundation\File\UploadedFile $image
1360
     */
1361
    public function setImageFile(File $image)
1362
    {
1363
        $this->imageFile = $image;
1364
1365
        if ($image) {
0 ignored issues
show
introduced by
$image is of type Symfony\Component\HttpFoundation\File\File, thus it always evaluated to true.
Loading history...
1366
            // It is required that at least one field changes if you are using doctrine
1367
            // otherwise the event listeners won't be called and the file is lost
1368
            $this->updatedAt = new \DateTime('now');
0 ignored issues
show
Bug Best Practice introduced by
The property updatedAt does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
1369
        }
1370
    }
1371
1372
    /**
1373
     * @return File
1374
     */
1375
    public function getImageFile()
1376
    {
1377
        return $this->imageFile;
1378
    }
1379
1380
    /**
1381
     * @param string $imageName
1382
     */
1383
    public function setImageName($imageName)
1384
    {
1385
        $this->imageName = $imageName;
0 ignored issues
show
Bug Best Practice introduced by
The property imageName does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
1386
    }
1387
1388
    /**
1389
     * @return string
1390
     */
1391
    public function getImageName()
1392
    {
1393
        return $this->imageName;
1394
    }
1395
1396
    /**
1397
     * @return string
1398
     */
1399
    public function getSlug()
1400
    {
1401
        return $this->getUsername();
1402
    }
1403
1404
    /**
1405
     * @param $slug
1406
     *
1407
     * @return User
1408
     */
1409
    public function setSlug($slug)
1410
    {
1411
        return $this->setUsername($slug);
1412
    }
1413
1414
    /**
1415
     * Set lastLogin.
1416
     *
1417
     * @param \DateTime $lastLogin
1418
     *
1419
     * @return User
1420
     */
1421
    public function setLastLogin(\DateTime $lastLogin = null)
1422
    {
1423
        $this->lastLogin = $lastLogin;
0 ignored issues
show
Bug Best Practice introduced by
The property lastLogin does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
1424
1425
        return $this;
1426
    }
1427
1428
    /**
1429
     * Get lastLogin.
1430
     *
1431
     * @return \DateTime
1432
     */
1433
    public function getLastLogin()
1434
    {
1435
        return $this->lastLogin;
1436
    }
1437
1438
    /**
1439
     * {@inheritdoc}
1440
     */
1441
    public function getExtraFields()
1442
    {
1443
        return $this->extraFields;
1444
    }
1445
1446
    /**
1447
     * {@inheritdoc}
1448
     */
1449
    public function setExtraFields($extraFields)
1450
    {
1451
        $this->extraFields = new ArrayCollection();
1452
        foreach ($extraFields as $extraField) {
1453
            $this->addExtraFields($extraField);
1454
        }
1455
1456
        return $this;
1457
    }
1458
1459
    /**
1460
     * {@inheritdoc}
1461
     */
1462
    /*public function addExtraFields(ExtraFieldValues $extraFieldValue)
1463
    {
1464
        $extraFieldValue->setUser($this);
1465
        $this->extraFields[] = $extraFieldValue;
1466
1467
        return $this;
1468
    }*/
1469
1470
    /**
1471
     * {@inheritdoc}
1472
     */
1473
    public function addExtraFields(ExtraFieldValues $extraFieldValue)
1474
    {
1475
        //if (!$this->hasExtraField($attribute)) {
1476
        $extraFieldValue->setUser($this);
0 ignored issues
show
Bug introduced by
The method setUser() does not exist on Chamilo\CoreBundle\Entity\ExtraFieldValues. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

1476
        $extraFieldValue->/** @scrutinizer ignore-call */ 
1477
                          setUser($this);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
1477
        $this->extraFields[] = $extraFieldValue;
1478
        //}
1479
1480
        return $this;
1481
    }
1482
1483
    /**
1484
     * {@inheritdoc}
1485
     */
1486
    public function removeExtraField(ExtraFieldValues $attribute)
1487
    {
1488
        //if ($this->hasExtraField($attribute)) {
1489
        //$this->extraFields->removeElement($attribute);
1490
        //$attribute->setUser($this);
1491
        //}
1492
1493
        return $this;
1494
    }
1495
1496
    /**
1497
     * {@inheritdoc}
1498
     */
1499
    /*public function hasExtraField($attribute)
1500
    {
1501
        if (!$this->extraFields) {
1502
            return false;
1503
        }
1504
        return $this->extraFields->contains($attribute);
1505
    }*/
1506
1507
    /**
1508
     * {@inheritdoc}
1509
     */
1510
    public function hasExtraFieldByName($attributeName)
1511
    {
1512
        foreach ($this->extraFields as $attribute) {
1513
            if ($attribute->getName() === $attributeName) {
1514
                return true;
1515
            }
1516
        }
1517
1518
        return false;
1519
    }
1520
1521
    /**
1522
     * {@inheritdoc}
1523
     */
1524
    public function getExtraFieldByName($attributeName)
1525
    {
1526
        foreach ($this->extraFields as $attribute) {
1527
            if ($attribute->getName() === $attributeName) {
1528
                return $attribute;
1529
            }
1530
        }
1531
1532
        return null;
1533
    }
1534
1535
    /**
1536
     * Get sessionCourseSubscription.
1537
     *
1538
     * @return ArrayCollection
1539
     */
1540
    public function getSessionCourseSubscriptions()
1541
    {
1542
        return $this->sessionCourseSubscriptions;
1543
    }
1544
1545
    /**
1546
     * @return string
1547
     */
1548
    public function getConfirmationToken()
1549
    {
1550
        return $this->confirmationToken;
1551
    }
1552
1553
    /**
1554
     * @param string $confirmationToken
1555
     *
1556
     * @return User
1557
     */
1558
    public function setConfirmationToken($confirmationToken)
1559
    {
1560
        $this->confirmationToken = $confirmationToken;
0 ignored issues
show
Bug Best Practice introduced by
The property confirmationToken does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
1561
1562
        return $this;
1563
    }
1564
1565
    /**
1566
     * @return \DateTime
1567
     */
1568
    public function getPasswordRequestedAt()
1569
    {
1570
        return $this->passwordRequestedAt;
1571
    }
1572
1573
    /**
1574
     * @param int $ttl
1575
     *
1576
     * @return bool
1577
     */
1578
    /*public function isPasswordRequestNonExpired($ttl)
1579
    {
1580
        return $this->getPasswordRequestedAt() instanceof \DateTime &&
1581
            $this->getPasswordRequestedAt()->getTimestamp() + $ttl > time();
1582
    }*/
1583
1584
    public function getUsername()
1585
    {
1586
        return $this->username;
1587
    }
1588
1589
    /**
1590
     * Returns the expiration date.
1591
     *
1592
     * @return \DateTime|null
1593
     */
1594
    public function getExpiresAt()
1595
    {
1596
        return $this->expiresAt;
1597
    }
1598
1599
    /**
1600
     * Returns the credentials expiration date.
1601
     *
1602
     * @return \DateTime
1603
     */
1604
    public function getCredentialsExpireAt()
1605
    {
1606
        return $this->credentialsExpireAt;
1607
    }
1608
1609
    /**
1610
     * Sets the credentials expiration date.
1611
     *
1612
     * @param \DateTime|null $date
1613
     *
1614
     * @return User
1615
     */
1616
    public function setCredentialsExpireAt(\DateTime $date = null)
1617
    {
1618
        $this->credentialsExpireAt = $date;
1619
1620
        return $this;
1621
    }
1622
1623
    /**
1624
     * Sets the user groups.
1625
     *
1626
     * @param array $groups
1627
     *
1628
     * @return User
1629
     */
1630
    public function setGroups($groups)
1631
    {
1632
        foreach ($groups as $group) {
1633
            $this->addGroup($group);
1634
        }
1635
1636
        return $this;
1637
    }
1638
1639
    /**
1640
     * @return string
1641
     */
1642
    public function getFullname()
1643
    {
1644
        return sprintf('%s %s', $this->getFirstname(), $this->getLastname());
1645
    }
1646
1647
    /**
1648
     * Returns the user roles.
1649
     *
1650
     * @return array The roles
1651
     */
1652
    public function getRoles()
1653
    {
1654
        $roles = $this->roles;
1655
1656
        foreach ($this->getGroups() as $group) {
1657
            $roles = array_merge($roles, $group->getRoles());
1658
        }
1659
1660
        // we need to make sure to have at least one role
1661
        $roles[] = static::ROLE_DEFAULT;
1662
1663
        return array_unique($roles);
1664
    }
1665
1666
    public function isAccountNonExpired()
1667
    {
1668
        /*if (true === $this->expired) {
1669
            return false;
1670
        }
1671
1672
        if (null !== $this->expiresAt && $this->expiresAt->getTimestamp() < time()) {
1673
            return false;
1674
        }*/
1675
1676
        return true;
1677
    }
1678
1679
    public function isAccountNonLocked()
1680
    {
1681
        return true;
1682
        //return !$this->locked;
1683
    }
1684
1685
    public function isCredentialsNonExpired()
1686
    {
1687
        /*if (true === $this->credentialsExpired) {
1688
            return false;
1689
        }
1690
1691
        if (null !== $this->credentialsExpireAt && $this->credentialsExpireAt->getTimestamp() < time()) {
1692
            return false;
1693
        }*/
1694
1695
        return true;
1696
    }
1697
1698
    /**
1699
     * @param bool $boolean
1700
     *
1701
     * @return User
1702
     */
1703
    public function setCredentialsExpired($boolean)
1704
    {
1705
        $this->credentialsExpired = $boolean;
1706
1707
        return $this;
1708
    }
1709
1710
    public function setEnabled($boolean)
1711
    {
1712
        $this->enabled = (bool) $boolean;
0 ignored issues
show
Bug Best Practice introduced by
The property enabled does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
1713
1714
        return $this;
1715
    }
1716
1717
    /**
1718
     * Sets this user to expired.
1719
     *
1720
     * @param bool $boolean
1721
     *
1722
     * @return User
1723
     */
1724
    public function setExpired($boolean)
1725
    {
1726
        $this->expired = (bool) $boolean;
1727
1728
        return $this;
1729
    }
1730
1731
    /**
1732
     * @param \DateTime $date
1733
     *
1734
     * @return User
1735
     */
1736
    public function setExpiresAt(\DateTime $date)
1737
    {
1738
        $this->expiresAt = $date;
1739
1740
        return $this;
1741
    }
1742
1743
    public function setLocked($boolean)
1744
    {
1745
        $this->locked = $boolean;
1746
1747
        return $this;
1748
    }
1749
1750
    public function setRoles(array $roles)
1751
    {
1752
        $this->roles = [];
0 ignored issues
show
Bug Best Practice introduced by
The property roles does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
1753
1754
        foreach ($roles as $role) {
1755
            $this->addRole($role);
1756
        }
1757
1758
        return $this;
1759
    }
1760
1761
    /**
1762
     * Get achievedSkills.
1763
     *
1764
     * @return ArrayCollection
1765
     */
1766
    public function getAchievedSkills()
1767
    {
1768
        return $this->achievedSkills;
1769
    }
1770
1771
    /**
1772
     * Check if the user has the skill.
1773
     *
1774
     * @param Skill $skill The skill
1775
     *
1776
     * @return bool
1777
     */
1778
    public function hasSkill(Skill $skill)
1779
    {
1780
        $achievedSkills = $this->getAchievedSkills();
1781
1782
        foreach ($achievedSkills as $userSkill) {
1783
            if ($userSkill->getSkill()->getId() !== $skill->getId()) {
1784
                continue;
1785
            }
1786
1787
            return true;
1788
        }
1789
    }
1790
1791
    /**
1792
     * @return bool
1793
     */
1794
    public function isProfileCompleted()
1795
    {
1796
        return $this->profileCompleted;
1797
    }
1798
1799
    /**
1800
     * @param mixed $profileCompleted
1801
     *
1802
     * @return User
1803
     */
1804
    public function setProfileCompleted($profileCompleted)
1805
    {
1806
        $this->profileCompleted = $profileCompleted;
1807
1808
        return $this;
1809
    }
1810
1811
    /**
1812
     * Sets the AccessUrl for the current user in memory.
1813
     *
1814
     * @param AccessUrl $url
1815
     *
1816
     * @return $this
1817
     */
1818
    public function setCurrentUrl(AccessUrl $url)
1819
    {
1820
        $urlList = $this->getPortals();
1821
        /** @var AccessUrlRelUser $item */
1822
        foreach ($urlList as $item) {
1823
            if ($item->getPortal()->getId() == $url->getId()) {
1824
                $this->currentUrl = $url;
1825
                break;
1826
            }
1827
        }
1828
1829
        return $this;
1830
    }
1831
1832
    /**
1833
     * @return AccessUrl
1834
     */
1835
    public function getCurrentUrl()
1836
    {
1837
        return $this->currentUrl;
1838
    }
1839
1840
    /**
1841
     * Get sessionAsGeneralCoach.
1842
     *
1843
     * @return ArrayCollection
1844
     */
1845
    public function getSessionAsGeneralCoach()
1846
    {
1847
        return $this->sessionAsGeneralCoach;
1848
    }
1849
1850
    /**
1851
     * @param UserInterface $user
1852
     *
1853
     * @return bool
1854
     */
1855
    public function isEqualTo(UserInterface $user)
1856
    {
1857
        if ($this->password !== $user->getPassword()) {
1858
            return false;
1859
        }
1860
1861
        if ($this->salt !== $user->getSalt()) {
1862
            return false;
1863
        }
1864
1865
        if ($this->username !== $user->getUsername()) {
1866
            return false;
1867
        }
1868
1869
        return true;
1870
    }
1871
1872
}
1873