]> git.immae.eu Git - github/wallabag/wallabag.git/blame - src/Wallabag/CoreBundle/Entity/Users.php
CS
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / Entity / Users.php
CommitLineData
9d50517c
NL
1<?php
2
ad4d1caa 3namespace Wallabag\CoreBundle\Entity;
9d50517c
NL
4
5use Doctrine\ORM\Mapping as ORM;
c3235553 6use Symfony\Component\Security\Core\User\UserInterface;
c3235553 7use Symfony\Component\Security\Core\User\AdvancedUserInterface;
9d50517c
NL
8
9/**
10 * Users
11 *
12 * @ORM\Table(name="users")
13 * @ORM\Entity
14 */
c3235553 15class Users implements AdvancedUserInterface, \Serializable
9d50517c
NL
16{
17 /**
18 * @var integer
19 *
20 * @ORM\Column(name="id", type="integer", nullable=true)
21 * @ORM\Id
22 * @ORM\GeneratedValue(strategy="IDENTITY")
23 */
24 private $id;
25
26 /**
27 * @var string
28 *
29 * @ORM\Column(name="username", type="text", nullable=true)
30 */
31 private $username;
32
c3235553
NL
33 /**
34 * @ORM\Column(type="string", length=32)
35 */
36 private $salt;
37
9d50517c
NL
38 /**
39 * @var string
40 *
41 * @ORM\Column(name="password", type="text", nullable=true)
42 */
43 private $password;
44
45 /**
46 * @var string
47 *
48 * @ORM\Column(name="name", type="text", nullable=true)
49 */
50 private $name;
51
52 /**
53 * @var string
54 *
55 * @ORM\Column(name="email", type="text", nullable=true)
56 */
57 private $email;
58
c3235553
NL
59 /**
60 * @ORM\Column(name="is_active", type="boolean")
61 */
62 private $isActive;
9d50517c 63
c3235553
NL
64 public function __construct()
65 {
66 $this->isActive = true;
67 $this->salt = md5(uniqid(null, true));
68 }
9d50517c
NL
69
70 /**
71 * Get id
72 *
7df80cb3 73 * @return integer
9d50517c
NL
74 */
75 public function getId()
76 {
77 return $this->id;
78 }
79
80 /**
81 * Set username
82 *
7df80cb3 83 * @param string $username
9d50517c
NL
84 * @return Users
85 */
86 public function setUsername($username)
87 {
88 $this->username = $username;
89
90 return $this;
91 }
92
93 /**
94 * Get username
95 *
7df80cb3 96 * @return string
9d50517c
NL
97 */
98 public function getUsername()
99 {
100 return $this->username;
101 }
102
c3235553
NL
103 /**
104 * @inheritDoc
105 */
106 public function getSalt()
107 {
108 return $this->salt;
109 }
110
111 /**
112 * @inheritDoc
113 */
114 public function getRoles()
115 {
116 return array('ROLE_USER');
117 }
118
9d50517c
NL
119 /**
120 * Set password
121 *
7df80cb3 122 * @param string $password
9d50517c
NL
123 * @return Users
124 */
125 public function setPassword($password)
126 {
127 $this->password = $password;
128
129 return $this;
130 }
131
132 /**
133 * Get password
134 *
7df80cb3 135 * @return string
9d50517c
NL
136 */
137 public function getPassword()
138 {
139 return $this->password;
140 }
141
142 /**
143 * Set name
144 *
7df80cb3 145 * @param string $name
9d50517c
NL
146 * @return Users
147 */
148 public function setName($name)
149 {
150 $this->name = $name;
151
152 return $this;
153 }
154
155 /**
156 * Get name
157 *
7df80cb3 158 * @return string
9d50517c
NL
159 */
160 public function getName()
161 {
162 return $this->name;
163 }
164
165 /**
166 * Set email
167 *
7df80cb3 168 * @param string $email
9d50517c
NL
169 * @return Users
170 */
171 public function setEmail($email)
172 {
173 $this->email = $email;
174
175 return $this;
176 }
177
178 /**
179 * Get email
180 *
7df80cb3 181 * @return string
9d50517c
NL
182 */
183 public function getEmail()
184 {
185 return $this->email;
186 }
c3235553
NL
187
188 /**
189 * @inheritDoc
190 */
191 public function eraseCredentials()
192 {
193 }
194
195 /**
196 * @see \Serializable::serialize()
197 */
198 public function serialize()
199 {
200 return serialize(array(
201 $this->id,
202 ));
203 }
204
205 /**
206 * @see \Serializable::unserialize()
207 */
208 public function unserialize($serialized)
209 {
7df80cb3 210 list(
c3235553
NL
211 $this->id,
212 ) = unserialize($serialized);
213 }
214
215 public function isEqualTo(UserInterface $user)
216 {
217 return $this->username === $user->getUsername();
218 }
219
220 public function isAccountNonExpired()
221 {
222 return true;
223 }
224
225 public function isAccountNonLocked()
226 {
227 return true;
228 }
229
230 public function isCredentialsNonExpired()
231 {
232 return true;
233 }
234
235 public function isEnabled()
236 {
237 return $this->isActive;
238 }
9d50517c 239}