1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace AppBundle\Entity; |
4
|
|
|
|
5
|
|
|
use Doctrine\ORM\Mapping as ORM; |
6
|
|
|
use Symfony\Component\Security\Core\User\UserInterface; |
7
|
|
|
use JMS\Serializer\Annotation\ExclusionPolicy; |
8
|
|
|
use JMS\Serializer\Annotation\Expose; |
9
|
|
|
use Symfony\Component\Validator\Constraints as Assert; |
10
|
|
|
use Symfony\Bridge\Doctrine\Validator\Constraints as DoctrineAssert; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* @ORM\Table(name="users") |
14
|
|
|
* @ORM\Entity(repositoryClass="AppBundle\Repository\UserRepository") |
15
|
|
|
* |
16
|
|
|
* @DoctrineAssert\UniqueEntity( |
17
|
|
|
* fields="facebookId", |
18
|
|
|
* message="facebookId already exists", |
19
|
|
|
* groups={"uniqFacebookId"} |
20
|
|
|
* ) |
21
|
|
|
* @DoctrineAssert\UniqueEntity( |
22
|
|
|
* fields="apiKey", |
23
|
|
|
* message="apikey already exists", |
24
|
|
|
* groups={"uniqApikey"} |
25
|
|
|
* ) |
26
|
|
|
* |
27
|
|
|
* @ExclusionPolicy("all") |
28
|
|
|
*/ |
29
|
|
|
class User implements UserInterface |
30
|
|
|
{ |
31
|
|
|
/** |
32
|
|
|
* @var int |
33
|
|
|
* |
34
|
|
|
* @ORM\Column(name="id", type="integer") |
35
|
|
|
* @ORM\Id |
36
|
|
|
* @ORM\GeneratedValue(strategy="AUTO") |
37
|
|
|
*/ |
38
|
|
|
protected $id; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @var string |
42
|
|
|
* |
43
|
|
|
* @ORM\Column(name="first_name", type="string", length=100, nullable=true) |
44
|
|
|
* |
45
|
|
|
* @Assert\Regex(pattern="/\d/", match=false) |
46
|
|
|
* @Assert\Type("string") |
47
|
|
|
* @Assert\Length(min=2, max=100) |
48
|
|
|
* @Assert\NotBlank( |
49
|
|
|
* message="not.blank" |
50
|
|
|
* ) |
51
|
|
|
* |
52
|
|
|
* @Expose |
53
|
|
|
*/ |
54
|
|
|
protected $firstName; |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @var string |
58
|
|
|
* |
59
|
|
|
* @ORM\Column(name="last_name", type="string", length=100, nullable=true) |
60
|
|
|
* |
61
|
|
|
* @Assert\Regex(pattern="/\d/", match=false) |
62
|
|
|
* @Assert\Type("string") |
63
|
|
|
* @Assert\Length(min=2, max=100) |
64
|
|
|
* @Assert\NotBlank( |
65
|
|
|
* message="not.blank" |
66
|
|
|
* ) |
67
|
|
|
* |
68
|
|
|
* @Expose |
69
|
|
|
*/ |
70
|
|
|
protected $lastName; |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @var string |
74
|
|
|
* |
75
|
|
|
* @ORM\Column(name="email", type="string", length=100, nullable=true) |
76
|
|
|
* |
77
|
|
|
* @Assert\Email() |
78
|
|
|
* @Assert\Type("string") |
79
|
|
|
* @Assert\Length(max=100) |
80
|
|
|
* @Assert\NotBlank( |
81
|
|
|
* message="not.blank" |
82
|
|
|
* ) |
83
|
|
|
* |
84
|
|
|
* @Expose |
85
|
|
|
*/ |
86
|
|
|
protected $email; |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* @var string |
90
|
|
|
* |
91
|
|
|
* @ORM\Column(name="username", type="string", length=100) |
92
|
|
|
* |
93
|
|
|
* @Assert\Type("string") |
94
|
|
|
* @Assert\Length(max=100) |
95
|
|
|
*/ |
96
|
|
|
protected $username; |
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* @var string |
100
|
|
|
* |
101
|
|
|
* @ORM\Column(name="api_key", type="string", length=255, nullable=true, unique=true) |
102
|
|
|
* |
103
|
|
|
* @Assert\Type("string") |
104
|
|
|
* @Assert\Length(max=255) |
105
|
|
|
*/ |
106
|
|
|
private $apiKey; |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* @var string |
110
|
|
|
* |
111
|
|
|
* @ORM\Column(name="facebook_id", type="string", length=255, nullable=true, unique=true) |
112
|
|
|
* |
113
|
|
|
* @Assert\Type("string") |
114
|
|
|
* @Assert\Length(max=255) |
115
|
|
|
*/ |
116
|
|
|
private $facebookId; |
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* @var string |
120
|
|
|
* |
121
|
|
|
* @ORM\Column(name="role", type="string", length=50) |
122
|
|
|
*/ |
123
|
|
|
private $role; |
124
|
|
|
|
125
|
|
|
/** |
126
|
|
|
* @return int |
127
|
|
|
*/ |
128
|
|
|
public function getId(): int |
129
|
|
|
{ |
130
|
|
|
return $this->id; |
131
|
|
|
} |
132
|
|
|
|
133
|
|
|
/** |
134
|
|
|
* @param string $apiKey |
135
|
|
|
* |
136
|
|
|
* @return User |
137
|
|
|
*/ |
138
|
30 |
|
public function setApiKey(?string $apiKey): User |
139
|
|
|
{ |
140
|
30 |
|
$this->apiKey = $apiKey; |
141
|
|
|
|
142
|
30 |
|
return $this; |
143
|
|
|
} |
144
|
|
|
|
145
|
|
|
/** |
146
|
|
|
* @return string |
147
|
|
|
*/ |
148
|
3 |
|
public function getApiKey(): ?string |
149
|
|
|
{ |
150
|
3 |
|
return $this->apiKey; |
151
|
|
|
} |
152
|
|
|
|
153
|
|
|
|
154
|
|
|
/** |
155
|
|
|
* @param string $role |
156
|
|
|
* |
157
|
|
|
* @return User |
158
|
|
|
*/ |
159
|
30 |
|
public function setRole(?string $role): User |
160
|
|
|
{ |
161
|
30 |
|
$this->role = $role; |
162
|
|
|
|
163
|
30 |
|
return $this; |
164
|
|
|
} |
165
|
|
|
|
166
|
|
|
/** |
167
|
|
|
* @return string |
168
|
|
|
*/ |
169
|
|
|
public function getRole(): ?string |
170
|
|
|
{ |
171
|
|
|
return $this->role; |
172
|
|
|
} |
173
|
|
|
|
174
|
|
|
|
175
|
|
|
|
176
|
|
|
/** |
177
|
|
|
* @inheritdoc |
178
|
|
|
*/ |
179
|
|
|
public function getRoles() |
180
|
|
|
{ |
181
|
|
|
return array($this->role); |
182
|
|
|
} |
183
|
|
|
|
184
|
|
|
/** |
185
|
|
|
* @inheritdoc |
186
|
|
|
*/ |
187
|
|
|
public function getPassword() |
188
|
|
|
{ |
189
|
|
|
} |
190
|
|
|
|
191
|
|
|
/** |
192
|
|
|
* @inheritdoc |
193
|
|
|
*/ |
194
|
|
|
public function getSalt() |
195
|
|
|
{ |
196
|
|
|
} |
197
|
|
|
|
198
|
|
|
/** |
199
|
|
|
* @inheritdoc |
200
|
|
|
*/ |
201
|
|
|
public function eraseCredentials() |
202
|
|
|
{ |
203
|
|
|
} |
204
|
|
|
|
205
|
|
|
/** |
206
|
|
|
* @param string $facebookId |
207
|
|
|
* |
208
|
|
|
* @return User |
209
|
|
|
*/ |
210
|
15 |
|
public function setFacebookId(?string $facebookId): User |
211
|
|
|
{ |
212
|
15 |
|
$this->facebookId = $facebookId; |
213
|
|
|
|
214
|
15 |
|
return $this; |
215
|
|
|
} |
216
|
|
|
|
217
|
|
|
/** |
218
|
|
|
* @return string |
219
|
|
|
*/ |
220
|
|
|
public function getFacebookId(): ?string |
221
|
|
|
{ |
222
|
|
|
return $this->facebookId; |
223
|
|
|
} |
224
|
|
|
|
225
|
|
|
/** |
226
|
|
|
* @param string $username |
227
|
|
|
* |
228
|
|
|
* @return User |
229
|
|
|
*/ |
230
|
30 |
|
public function setUsername(?string $username): User |
231
|
|
|
{ |
232
|
30 |
|
$this->username = $username; |
233
|
|
|
|
234
|
30 |
|
return $this; |
235
|
|
|
} |
236
|
|
|
|
237
|
|
|
/** |
238
|
|
|
* @return string |
239
|
|
|
*/ |
240
|
|
|
public function getUsername(): ?string |
241
|
|
|
{ |
242
|
|
|
return $this->username; |
243
|
|
|
} |
244
|
|
|
|
245
|
|
|
/** |
246
|
|
|
* @param string $firstName |
247
|
|
|
* |
248
|
|
|
* @return User |
249
|
|
|
*/ |
250
|
|
|
public function setFirstName(?string $firstName): User |
251
|
|
|
{ |
252
|
|
|
$this->firstName = $firstName; |
253
|
|
|
|
254
|
|
|
return $this; |
255
|
|
|
} |
256
|
|
|
|
257
|
|
|
/** |
258
|
|
|
* @return string |
259
|
|
|
*/ |
260
|
|
|
public function getFirstName(): ?string |
261
|
|
|
{ |
262
|
|
|
return $this->firstName; |
263
|
|
|
} |
264
|
|
|
|
265
|
|
|
/** |
266
|
|
|
* @param string $lastName |
267
|
|
|
* |
268
|
|
|
* @return User |
269
|
|
|
*/ |
270
|
|
|
public function setLastName(?string $lastName): User |
271
|
|
|
{ |
272
|
|
|
$this->lastName = $lastName; |
273
|
|
|
|
274
|
|
|
return $this; |
275
|
|
|
} |
276
|
|
|
|
277
|
|
|
/** |
278
|
|
|
* @return string |
279
|
|
|
*/ |
280
|
|
|
public function getLastName(): ?string |
281
|
|
|
{ |
282
|
|
|
return $this->lastName; |
283
|
|
|
} |
284
|
|
|
|
285
|
|
|
/** |
286
|
|
|
* @param string $email |
287
|
|
|
* |
288
|
|
|
* @return User |
289
|
|
|
*/ |
290
|
|
|
public function setEmail(?string $email): User |
291
|
|
|
{ |
292
|
|
|
$this->email = $email; |
293
|
|
|
|
294
|
|
|
return $this; |
295
|
|
|
} |
296
|
|
|
|
297
|
|
|
/** |
298
|
|
|
* @return string |
299
|
|
|
*/ |
300
|
|
|
public function getEmail(): ?string |
301
|
|
|
{ |
302
|
|
|
return $this->email; |
303
|
|
|
} |
304
|
|
|
} |
305
|
|
|
|