1 | <?php |
||
22 | class User implements UserInterface, IdentityInterface, JsonSerializable |
||
23 | { |
||
24 | /** |
||
25 | * @var int |
||
26 | * |
||
27 | * @ORM\Id |
||
28 | * @ORM\Column(type="integer") |
||
29 | * @ORM\GeneratedValue(strategy="AUTO") |
||
30 | */ |
||
31 | protected $id; |
||
32 | |||
33 | /** |
||
34 | * @var string |
||
35 | * |
||
36 | * @ORM\Column(type="string", unique=true, length=255, nullable=false) |
||
37 | */ |
||
38 | protected $email; |
||
39 | |||
40 | /** |
||
41 | * @var string |
||
42 | * @ORM\Column(type="string", unique=true, length=255, nullable=true) |
||
43 | */ |
||
44 | protected $username; |
||
45 | |||
46 | /** |
||
47 | * @var string |
||
48 | * |
||
49 | * @ORM\Column(type="string", name="display_name", length=50, nullable=true) |
||
50 | */ |
||
51 | protected $displayName; |
||
52 | |||
53 | /** |
||
54 | * @var string |
||
55 | * |
||
56 | * @ORM\Column(type="string", length=128) |
||
57 | */ |
||
58 | protected $password; |
||
59 | |||
60 | /** |
||
61 | * @var int |
||
62 | * |
||
63 | * @ORM\Column(type="integer", name="state", nullable=true) |
||
64 | */ |
||
65 | protected $state; |
||
66 | |||
67 | /** |
||
68 | * @var \DateTime |
||
69 | * |
||
70 | * @ORM\Column(type="datetime", name="created_at", nullable=false) |
||
71 | */ |
||
72 | protected $createdAt; |
||
73 | |||
74 | /** |
||
75 | * @var \Doctrine\Common\Collections\Collection |
||
76 | * |
||
77 | * @ORM\ManyToMany(targetEntity="JhUser\Entity\HierarchicalRole") |
||
78 | * @ORM\JoinTable(name="user_role", |
||
79 | * joinColumns={@ORM\JoinColumn(name="user_id", referencedColumnName="id")}, |
||
80 | * inverseJoinColumns={@ORM\JoinColumn(name="role_id", referencedColumnName="id")} |
||
81 | * ) |
||
82 | */ |
||
83 | protected $roles; |
||
84 | |||
85 | /** |
||
86 | * Initialise the roles variable. |
||
87 | */ |
||
88 | public function __construct() |
||
92 | |||
93 | /** |
||
94 | * @return int |
||
95 | */ |
||
96 | public function getId() |
||
100 | |||
101 | /** |
||
102 | * @param int $id |
||
103 | * @return \JhUser\Entity\User |
||
104 | */ |
||
105 | public function setId($id) |
||
110 | |||
111 | /** |
||
112 | * @return string |
||
113 | */ |
||
114 | public function getEmail() |
||
118 | |||
119 | /** |
||
120 | * @param string $email |
||
121 | * @return \JhUser\Entity\User |
||
122 | */ |
||
123 | public function setEmail($email) |
||
128 | |||
129 | /** |
||
130 | * @return string |
||
131 | */ |
||
132 | public function getUsername() |
||
136 | |||
137 | /** |
||
138 | * @param string $username |
||
139 | * @return \JhUser\Entity\User |
||
140 | */ |
||
141 | public function setUsername($username) |
||
146 | |||
147 | /** |
||
148 | * @return string |
||
149 | */ |
||
150 | public function getDisplayName() |
||
158 | |||
159 | /** |
||
160 | * @param string $displayName |
||
161 | * @return \JhUser\Entity\User |
||
162 | */ |
||
163 | public function setDisplayName($displayName) |
||
168 | |||
169 | /** |
||
170 | * @return string |
||
171 | */ |
||
172 | public function getPassword() |
||
176 | |||
177 | /** |
||
178 | * @param string $password |
||
179 | * @return \JhUser\Entity\User |
||
180 | */ |
||
181 | public function setPassword($password) |
||
186 | |||
187 | /** |
||
188 | * @return int |
||
189 | */ |
||
190 | public function getState() |
||
194 | |||
195 | /** |
||
196 | * @param int|null $state |
||
197 | * @return \JhUser\Entity\User |
||
198 | */ |
||
199 | public function setState($state) |
||
204 | |||
205 | /** |
||
206 | * @return \DateTime |
||
207 | */ |
||
208 | public function getCreatedAt() |
||
212 | |||
213 | /** |
||
214 | * @param \DateTime $createdAt |
||
215 | * @return \JhUser\Entity\User |
||
216 | */ |
||
217 | public function setCreatedAt(\DateTime $createdAt) |
||
222 | |||
223 | /** |
||
224 | * @return array |
||
225 | */ |
||
226 | public function getRoles() |
||
230 | |||
231 | /** |
||
232 | * Set the list of roles |
||
233 | * @param Collection $roles |
||
234 | */ |
||
235 | public function setRoles(Collection $roles) |
||
242 | |||
243 | /** |
||
244 | * Add one role to roles list |
||
245 | * @param \Rbac\Role\RoleInterface $role |
||
246 | */ |
||
247 | public function addRole(RoleInterface $role) |
||
251 | |||
252 | /** |
||
253 | * Remove a particular role from a user |
||
254 | * |
||
255 | * @param RoleInterface $removeRole |
||
256 | */ |
||
257 | public function removeRole(RoleInterface $removeRole) |
||
265 | |||
266 | /** |
||
267 | * @return array |
||
268 | */ |
||
269 | public function jsonSerialize() |
||
278 | |||
279 | /** |
||
280 | * @ORM\PrePersist |
||
281 | */ |
||
282 | public function setCreatedAtDate() |
||
286 | } |
||
287 |