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