]> Raphaƫl G. Git Repositories - userbundle/blob - Entity/User.php
Remove cannotBeEmpty() requirement on empty keys
[userbundle] / Entity / User.php
1 <?php
2
3 // src/Rapsys/UserBundle/Entity/User.php
4 namespace Rapsys\UserBundle\Entity;
5
6 class User implements \Symfony\Component\Security\Core\User\AdvancedUserInterface, \Serializable {
7 /**
8 * @var integer
9 */
10 protected $id;
11
12 /**
13 * @var string
14 */
15 protected $mail;
16
17 /**
18 * @var string
19 */
20 protected $pseudonym;
21
22 /**
23 * @var string
24 */
25 protected $forename;
26
27 /**
28 * @var string
29 */
30 protected $surname;
31
32 /**
33 * @var string
34 */
35 protected $password;
36
37 /**
38 * @var bool
39 */
40 protected $active;
41
42 /**
43 * @var \DateTime
44 */
45 protected $created;
46
47 /**
48 * @var \DateTime
49 */
50 protected $updated;
51
52 /**
53 * @var \Rapsys\UserBundle\Entity\Title
54 */
55 protected $title;
56
57 /**
58 * @var \Doctrine\Common\Collections\Collection
59 */
60 protected $groups;
61
62 /**
63 * User constructor.
64 */
65 public function __construct() {
66 $this->active = false;
67 $this->groups = new \Doctrine\Common\Collections\ArrayCollection();
68 }
69
70 /**
71 * Get id
72 *
73 * @return integer
74 */
75 public function getId() {
76 return $this->id;
77 }
78
79 /**
80 * Set mail
81 *
82 * @param string $mail
83 *
84 * @return User
85 */
86 public function setMail($mail) {
87 $this->mail = $mail;
88
89 return $this;
90 }
91
92 /**
93 * Get mail
94 *
95 * @return string
96 */
97 public function getMail() {
98 return $this->mail;
99 }
100
101 /**
102 * Set pseudonym
103 *
104 * @param string $pseudonym
105 *
106 * @return User
107 */
108 public function setPseudonym($pseudonym) {
109 $this->pseudonym = $pseudonym;
110
111 return $this;
112 }
113
114 /**
115 * Get pseudonym
116 *
117 * @return string
118 */
119 public function getPseudonym() {
120 return $this->pseudonym;
121 }
122
123 /**
124 * Set forename
125 *
126 * @param string $forename
127 *
128 * @return User
129 */
130 public function setForename($forename) {
131 $this->forename = $forename;
132
133 return $this;
134 }
135
136 /**
137 * Get forename
138 *
139 * @return string
140 */
141 public function getForename() {
142 return $this->forename;
143 }
144
145 /**
146 * Set surname
147 *
148 * @param string $surname
149 *
150 * @return User
151 */
152 public function setSurname($surname) {
153 $this->surname = $surname;
154
155 return $this;
156 }
157
158 /**
159 * Get surname
160 *
161 * @return string
162 */
163 public function getSurname() {
164 return $this->surname;
165 }
166
167 /**
168 * Set password
169 *
170 * @param string $password
171 *
172 * @return User
173 */
174 public function setPassword($password) {
175 $this->password = $password;
176
177 return $this;
178 }
179
180 /**
181 * Get password
182 *
183 * @return string
184 */
185 public function getPassword() {
186 return $this->password;
187 }
188
189 /**
190 * Set active
191 *
192 * @param bool $active
193 *
194 * @return User
195 */
196 public function setActive($active) {
197 $this->active = $active;
198
199 return $this;
200 }
201
202 /**
203 * Get active
204 *
205 * @return bool
206 */
207 public function getActive() {
208 return $this->active;
209 }
210
211 /**
212 * Set created
213 *
214 * @param \DateTime $created
215 *
216 * @return User
217 */
218 public function setCreated($created) {
219 $this->created = $created;
220
221 return $this;
222 }
223
224 /**
225 * Get created
226 *
227 * @return \DateTime
228 */
229 public function getCreated() {
230 return $this->created;
231 }
232
233 /**
234 * Set updated
235 *
236 * @param \DateTime $updated
237 *
238 * @return User
239 */
240 public function setUpdated($updated) {
241 $this->updated = $updated;
242
243 return $this;
244 }
245
246 /**
247 * Get updated
248 *
249 * @return \DateTime
250 */
251 public function getUpdated() {
252 return $this->updated;
253 }
254
255 /**
256 * Set title
257 */
258 public function setTitle($title) {
259 $this->title = $title;
260
261 return $this;
262 }
263
264 /**
265 * Get title
266 */
267 public function getTitle() {
268 return $this->title;
269 }
270
271 /**
272 * Add group
273 *
274 * @param \Rapsys\UserBundle\Entity\Group $group
275 *
276 * @return User
277 */
278 public function addGroup(\Rapsys\UserBundle\Entity\Group $group) {
279 $this->groups[] = $group;
280
281 return $this;
282 }
283
284 /**
285 * Remove group
286 *
287 * @param \Rapsys\UserBundle\Entity\Group $group
288 */
289 public function removeGroup(\Rapsys\UserBundle\Entity\Group $group) {
290 $this->groups->removeElement($group);
291 }
292
293 /**
294 * Get groups
295 *
296 * @return \Doctrine\Common\Collections\Collection
297 */
298 public function getGroups() {
299 return $this->groups;
300 }
301
302 public function getRoles() {
303 return $this->groups->toArray();
304 }
305
306 public function getSalt() {
307 //No salt required with bcrypt
308 return null;
309 }
310
311 public function getUsername() {
312 return $this->mail;
313 }
314
315 public function eraseCredentials() {
316 }
317
318 public function serialize() {
319 return serialize(array(
320 $this->id,
321 $this->mail,
322 $this->password,
323 $this->active,
324 $this->created,
325 $this->updated
326 ));
327 }
328
329 public function unserialize($serialized) {
330 list(
331 $this->id,
332 $this->mail,
333 $this->password,
334 $this->active,
335 $this->created,
336 $this->updated
337 ) = unserialize($serialized);
338 }
339
340 public function isAccountNonExpired() {
341 return true;
342 }
343
344 public function isAccountNonLocked() {
345 return true;
346 }
347
348 public function isCredentialsNonExpired() {
349 return true;
350 }
351
352 public function isEnabled() {
353 return $this->active;
354 }
355 }