3 namespace Wallabag\CoreBundle\Entity
;
5 use Doctrine\ORM\Mapping
as ORM
;
6 use Symfony\Component\Security\Core\User\UserInterface
;
7 use Symfony\Component\Security\Core\User\AdvancedUserInterface
;
12 * @ORM\Table(name="user")
14 * @ORM\HasLifecycleCallbacks()
16 class User
implements AdvancedUserInterface
, \Serializable
21 * @ORM\Column(name="id", type="integer")
23 * @ORM\GeneratedValue(strategy="AUTO")
30 * @ORM\Column(name="username", type="text")
37 * @ORM\Column(type="string", length=32)
44 * @ORM\Column(name="password", type="text")
51 * @ORM\Column(name="name", type="text", nullable=true)
58 * @ORM\Column(name="email", type="text", nullable=true)
63 * @ORM\Column(name="is_active", type="boolean")
70 * @ORM\Column(name="created_at", type="datetime")
77 * @ORM\Column(name="updated_at", type="datetime")
81 public function __construct()
83 $this->isActive
= true;
84 $this->salt
= md5(uniqid(null, true));
91 public function timestamps()
93 if (is_null($this->createdAt
)) {
94 $this->createdAt
= new \
DateTime();
97 $this->updatedAt
= new \
DateTime();
105 public function getId()
113 * @param string $username
116 public function setUsername($username)
118 $this->username
= $username;
128 public function getUsername()
130 return $this->username
;
136 public function getSalt()
144 public function getRoles()
146 return array('ROLE_USER');
152 * @param string $password
155 public function setPassword($password)
157 $this->password
= $password;
167 public function getPassword()
169 return $this->password
;
175 * @param string $name
178 public function setName($name)
190 public function getName()
198 * @param string $email
201 public function setEmail($email)
203 $this->email
= $email;
213 public function getEmail()
221 public function getCreatedAt()
223 return $this->createdAt
;
229 public function getUpdatedAt()
231 return $this->updatedAt
;
237 public function eraseCredentials()
242 * @see \Serializable::serialize()
244 public function serialize()
246 return serialize(array(
252 * @see \Serializable::unserialize()
254 public function unserialize($serialized)
258 ) = unserialize($serialized);
261 public function isEqualTo(UserInterface
$user)
263 return $this->username
=== $user->getUsername();
266 public function isAccountNonExpired()
271 public function isAccountNonLocked()
276 public function isCredentialsNonExpired()
281 public function isEnabled()
283 return $this->isActive
;