1
|
|
|
<?php |
2
|
|
|
declare(strict_types=1); |
3
|
|
|
|
4
|
|
|
namespace App\Entity; |
5
|
|
|
|
6
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
7
|
|
|
use Doctrine\ORM\Mapping as ORM; |
8
|
|
|
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface; |
9
|
|
|
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; |
10
|
|
|
use Symfony\Component\Security\Core\User\UserInterface; |
11
|
|
|
use JMS\Serializer\Annotation\Exclude; |
12
|
|
|
use JMS\Serializer\Annotation\Expose; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* @ORM\Entity |
16
|
|
|
* @ORM\Table(name="users_profiles") |
17
|
|
|
*/ |
18
|
|
|
class UserProfile |
19
|
|
|
{ |
20
|
|
|
/** |
21
|
|
|
* @ORM\Id() |
22
|
|
|
* @ORM\GeneratedValue() |
23
|
|
|
* @ORM\Column(type="integer") |
24
|
|
|
*/ |
25
|
|
|
private $id; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @var $user User |
29
|
|
|
* @ORM\OneToOne(targetEntity="App\Entity\User", inversedBy="profile") |
30
|
|
|
* @ORM\JoinColumn(nullable=false) |
31
|
|
|
*/ |
32
|
|
|
private $user; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @var $contacts UserProfileContacts[]|ArrayCollection |
36
|
|
|
* @ORM\OneToMany(targetEntity="App\Entity\UserProfileContacts", mappedBy="contacts", cascade={"persist", "remove"}) |
37
|
|
|
* @ORM\JoinColumn(nullable=true) |
38
|
|
|
*/ |
39
|
|
|
private $contacts; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @ORM\Column(type="string", length=255, nullable=true) |
43
|
|
|
*/ |
44
|
|
|
public $first_name; |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @ORM\Column(type="string", length=255, nullable=true) |
48
|
|
|
*/ |
49
|
|
|
public $last_name; |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @ORM\Column(type="date", nullable=true) |
53
|
|
|
*/ |
54
|
|
|
private $birth_date; |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @ORM\Column(type="string", length=255, nullable=true) |
58
|
|
|
*/ |
59
|
|
|
public $about; |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* @ORM\Column(type="string", length=255, nullable=true) |
63
|
|
|
*/ |
64
|
|
|
public $public_email; |
65
|
|
|
|
66
|
22 |
|
public function __construct(User $user) |
67
|
|
|
{ |
68
|
22 |
|
$this->user = $user; |
69
|
22 |
|
$this->contacts = new ArrayCollection(); |
70
|
22 |
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @return mixed |
74
|
|
|
*/ |
75
|
1 |
|
public function getId() |
76
|
|
|
{ |
77
|
1 |
|
return $this->id; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* @return User |
82
|
|
|
*/ |
83
|
1 |
|
public function getUser(): User |
84
|
|
|
{ |
85
|
1 |
|
return $this->user; |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* @return mixed |
90
|
|
|
*/ |
91
|
2 |
|
public function getBirthDate() |
92
|
|
|
{ |
93
|
2 |
|
return $this->birth_date; |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* @param \DateTime $birth_date |
98
|
|
|
* @return UserProfile |
99
|
|
|
*/ |
100
|
1 |
|
public function setBirthDate(\DateTime $birth_date) |
101
|
|
|
{ |
102
|
1 |
|
$this->birth_date = $birth_date; |
103
|
1 |
|
return $this; |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
/** |
107
|
|
|
* @return UserProfileContacts[]|ArrayCollection |
108
|
|
|
*/ |
109
|
2 |
|
public function getContacts() |
110
|
|
|
{ |
111
|
2 |
|
return $this->contacts; |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
/** |
115
|
|
|
* @param $name |
116
|
|
|
* @param $url |
117
|
|
|
* @return $this |
118
|
|
|
*/ |
119
|
1 |
|
public function addContacts($name, $url) |
120
|
|
|
{ |
121
|
1 |
|
$contact = new UserProfileContacts($this); |
122
|
1 |
|
$contact->provider = $name; |
123
|
1 |
|
$contact->url = $url; |
124
|
|
|
|
125
|
1 |
|
$this->contacts->add($contact); |
126
|
|
|
|
127
|
1 |
|
return $this; |
128
|
|
|
} |
129
|
|
|
} |