1
|
|
|
<?php |
2
|
|
|
declare(strict_types=1); |
3
|
|
|
|
4
|
|
|
namespace App\Users\Entity; |
5
|
|
|
|
6
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
7
|
|
|
use Doctrine\ORM\Mapping as ORM; |
8
|
|
|
use JMS\Serializer\Annotation\ExclusionPolicy; |
9
|
|
|
use JMS\Serializer\Annotation\Expose; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* @ORM\Entity |
13
|
|
|
* @ORM\Table(name="users_profiles") |
14
|
|
|
* @ExclusionPolicy("all") |
15
|
|
|
*/ |
16
|
|
|
class UserProfile |
17
|
|
|
{ |
18
|
|
|
/** |
19
|
|
|
* @ORM\Id() |
20
|
|
|
* @ORM\GeneratedValue() |
21
|
|
|
* @ORM\Column(type="integer") |
22
|
|
|
*/ |
23
|
|
|
private $id; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @var $user User |
27
|
|
|
* @ORM\OneToOne(targetEntity="App\Users\Entity\User", inversedBy="profile") |
28
|
|
|
* @ORM\JoinColumn(nullable=false) |
29
|
|
|
*/ |
30
|
|
|
private $user; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @var $contacts UserProfileContacts[]|ArrayCollection |
34
|
|
|
* @ORM\OneToMany(targetEntity="App\Users\Entity\UserProfileContacts", mappedBy="profile", cascade={"persist", "remove"}) |
35
|
|
|
* @ORM\JoinColumn(nullable=true) |
36
|
|
|
* @Expose |
37
|
|
|
*/ |
38
|
|
|
private $contacts; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @ORM\Column(type="string", length=255, nullable=true) |
42
|
|
|
* @Expose |
43
|
|
|
*/ |
44
|
|
|
private $first_name; |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @ORM\Column(type="string", length=255, nullable=true) |
48
|
|
|
* @Expose |
49
|
|
|
*/ |
50
|
|
|
private $last_name; |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @ORM\Column(type="date", nullable=true) |
54
|
|
|
* @Expose |
55
|
|
|
*/ |
56
|
|
|
private $birth_date; |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @ORM\Column(type="string", length=255, nullable=true) |
60
|
|
|
* @Expose |
61
|
|
|
*/ |
62
|
|
|
private $about; |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @ORM\Column(type="string", length=255, nullable=true) |
66
|
|
|
* @Expose |
67
|
|
|
*/ |
68
|
31 |
|
private $public_email; |
69
|
|
|
|
70
|
31 |
|
public function __construct(User $user) |
71
|
31 |
|
{ |
72
|
31 |
|
$this->user = $user; |
73
|
|
|
$this->contacts = new ArrayCollection(); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
1 |
|
* @return mixed |
78
|
|
|
*/ |
79
|
1 |
|
public function getFirstName() |
80
|
|
|
{ |
81
|
|
|
return $this->first_name; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
1 |
|
* @param mixed $first_name |
86
|
|
|
* @return UserProfile |
87
|
1 |
|
*/ |
88
|
|
|
public function setFirstName($first_name) |
89
|
|
|
{ |
90
|
|
|
$this->first_name = $first_name; |
91
|
|
|
return $this; |
92
|
|
|
} |
93
|
2 |
|
|
94
|
|
|
/** |
95
|
2 |
|
* @return mixed |
96
|
|
|
*/ |
97
|
|
|
public function getLastName() |
98
|
|
|
{ |
99
|
|
|
return $this->last_name; |
100
|
|
|
} |
101
|
|
|
|
102
|
1 |
|
/** |
103
|
|
|
* @param mixed $last_name |
104
|
1 |
|
* @return UserProfile |
105
|
1 |
|
*/ |
106
|
|
|
public function setLastName($last_name) |
107
|
|
|
{ |
108
|
|
|
$this->last_name = $last_name; |
109
|
|
|
return $this; |
110
|
|
|
} |
111
|
2 |
|
|
112
|
|
|
/** |
113
|
2 |
|
* @return mixed |
114
|
|
|
*/ |
115
|
|
|
public function getAbout() |
116
|
|
|
{ |
117
|
|
|
return $this->about; |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
/** |
121
|
1 |
|
* @param mixed $about |
122
|
|
|
* @return UserProfile |
123
|
1 |
|
*/ |
124
|
1 |
|
public function setAbout($about) |
125
|
1 |
|
{ |
126
|
|
|
$this->about = $about; |
127
|
1 |
|
return $this; |
128
|
|
|
} |
129
|
1 |
|
|
130
|
|
|
/** |
131
|
|
|
* @return mixed |
132
|
|
|
*/ |
133
|
|
|
public function getPublicEmail() |
134
|
|
|
{ |
135
|
|
|
return $this->public_email; |
136
|
|
|
} |
137
|
|
|
|
138
|
|
|
/** |
139
|
|
|
* @param mixed $public_email |
140
|
|
|
* @return UserProfile |
141
|
|
|
*/ |
142
|
|
|
public function setPublicEmail($public_email) |
143
|
|
|
{ |
144
|
|
|
$this->public_email = $public_email; |
145
|
|
|
return $this; |
146
|
|
|
} |
147
|
|
|
|
148
|
|
|
/** |
149
|
|
|
* @return mixed |
150
|
|
|
*/ |
151
|
|
|
public function getId() |
152
|
|
|
{ |
153
|
|
|
return $this->id; |
154
|
|
|
} |
155
|
|
|
|
156
|
|
|
/** |
157
|
|
|
* @return User |
158
|
|
|
*/ |
159
|
|
|
public function getUser(): User |
160
|
|
|
{ |
161
|
|
|
return $this->user; |
162
|
|
|
} |
163
|
|
|
|
164
|
|
|
/** |
165
|
|
|
* @return mixed |
166
|
|
|
*/ |
167
|
|
|
public function getBirthDate() |
168
|
|
|
{ |
169
|
|
|
return $this->birth_date; |
170
|
|
|
} |
171
|
|
|
|
172
|
|
|
/** |
173
|
|
|
* @param \DateTime $birth_date |
174
|
|
|
* @return UserProfile |
175
|
|
|
*/ |
176
|
|
|
public function setBirthDate(\DateTime $birth_date) |
177
|
|
|
{ |
178
|
|
|
$this->birth_date = $birth_date; |
179
|
|
|
return $this; |
180
|
|
|
} |
181
|
|
|
|
182
|
|
|
/** |
183
|
|
|
* @return UserProfileContacts[]|ArrayCollection |
184
|
|
|
*/ |
185
|
|
|
public function getContacts() |
186
|
|
|
{ |
187
|
|
|
return $this->contacts; |
188
|
|
|
} |
189
|
|
|
|
190
|
|
|
/** |
191
|
|
|
* @param $name |
192
|
|
|
* @param $url |
193
|
|
|
* @return $this |
194
|
|
|
*/ |
195
|
|
|
public function addContacts($name, $url) |
196
|
|
|
{ |
197
|
|
|
$contact = new UserProfileContacts($this, $name, $url); |
198
|
|
|
$this->contacts->add($contact); |
199
|
|
|
return $this; |
200
|
|
|
} |
201
|
|
|
} |