]> git.immae.eu Git - github/wallabag/wallabag.git/blob - src/Wallabag/CoreBundle/Entity/Users.php
CS
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / Entity / Users.php
1 <?php
2
3 namespace Wallabag\CoreBundle\Entity;
4
5 use Doctrine\ORM\Mapping as ORM;
6 use Symfony\Component\Security\Core\User\UserInterface;
7 use Symfony\Component\Security\Core\User\AdvancedUserInterface;
8
9 /**
10 * Users
11 *
12 * @ORM\Table(name="users")
13 * @ORM\Entity
14 */
15 class Users implements AdvancedUserInterface, \Serializable
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
33 /**
34 * @ORM\Column(type="string", length=32)
35 */
36 private $salt;
37
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
59 /**
60 * @ORM\Column(name="is_active", type="boolean")
61 */
62 private $isActive;
63
64 public function __construct()
65 {
66 $this->isActive = true;
67 $this->salt = md5(uniqid(null, true));
68 }
69
70 /**
71 * Get id
72 *
73 * @return integer
74 */
75 public function getId()
76 {
77 return $this->id;
78 }
79
80 /**
81 * Set username
82 *
83 * @param string $username
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 *
96 * @return string
97 */
98 public function getUsername()
99 {
100 return $this->username;
101 }
102
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
119 /**
120 * Set password
121 *
122 * @param string $password
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 *
135 * @return string
136 */
137 public function getPassword()
138 {
139 return $this->password;
140 }
141
142 /**
143 * Set name
144 *
145 * @param string $name
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 *
158 * @return string
159 */
160 public function getName()
161 {
162 return $this->name;
163 }
164
165 /**
166 * Set email
167 *
168 * @param string $email
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 *
181 * @return string
182 */
183 public function getEmail()
184 {
185 return $this->email;
186 }
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 {
210 list(
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 }
239 }