wallabag/src/Wallabag/CoreBundle/Entity/Users.php

240 lines
3.8 KiB
PHP
Raw Normal View History

2015-01-22 16:18:56 +00:00
<?php
namespace Wallabag\CoreBundle\Entity;
2015-01-22 16:18:56 +00:00
use Doctrine\ORM\Mapping as ORM;
2015-01-31 14:14:10 +00:00
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Security\Core\User\AdvancedUserInterface;
2015-01-22 16:18:56 +00:00
/**
* Users
*
* @ORM\Table(name="users")
* @ORM\Entity
*/
2015-01-31 14:14:10 +00:00
class Users implements AdvancedUserInterface, \Serializable
2015-01-22 16:18:56 +00:00
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer", nullable=true)
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="username", type="text", nullable=true)
*/
private $username;
2015-01-31 14:14:10 +00:00
/**
* @ORM\Column(type="string", length=32)
*/
private $salt;
2015-01-22 16:18:56 +00:00
/**
* @var string
*
* @ORM\Column(name="password", type="text", nullable=true)
*/
private $password;
/**
* @var string
*
* @ORM\Column(name="name", type="text", nullable=true)
*/
private $name;
/**
* @var string
*
* @ORM\Column(name="email", type="text", nullable=true)
*/
private $email;
2015-01-31 14:14:10 +00:00
/**
* @ORM\Column(name="is_active", type="boolean")
*/
private $isActive;
2015-01-22 16:18:56 +00:00
2015-01-31 14:14:10 +00:00
public function __construct()
{
$this->isActive = true;
$this->salt = md5(uniqid(null, true));
}
2015-01-22 16:18:56 +00:00
/**
* Get id
*
2015-01-31 18:09:34 +00:00
* @return integer
2015-01-22 16:18:56 +00:00
*/
public function getId()
{
return $this->id;
}
/**
* Set username
*
2015-01-31 18:09:34 +00:00
* @param string $username
2015-01-22 16:18:56 +00:00
* @return Users
*/
public function setUsername($username)
{
$this->username = $username;
return $this;
}
/**
* Get username
*
2015-01-31 18:09:34 +00:00
* @return string
2015-01-22 16:18:56 +00:00
*/
public function getUsername()
{
return $this->username;
}
2015-01-31 14:14:10 +00:00
/**
* @inheritDoc
*/
public function getSalt()
{
return $this->salt;
}
/**
* @inheritDoc
*/
public function getRoles()
{
return array('ROLE_USER');
}
2015-01-22 16:18:56 +00:00
/**
* Set password
*
2015-01-31 18:09:34 +00:00
* @param string $password
2015-01-22 16:18:56 +00:00
* @return Users
*/
public function setPassword($password)
{
$this->password = $password;
return $this;
}
/**
* Get password
*
2015-01-31 18:09:34 +00:00
* @return string
2015-01-22 16:18:56 +00:00
*/
public function getPassword()
{
return $this->password;
}
/**
* Set name
*
2015-01-31 18:09:34 +00:00
* @param string $name
2015-01-22 16:18:56 +00:00
* @return Users
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name
*
2015-01-31 18:09:34 +00:00
* @return string
2015-01-22 16:18:56 +00:00
*/
public function getName()
{
return $this->name;
}
/**
* Set email
*
2015-01-31 18:09:34 +00:00
* @param string $email
2015-01-22 16:18:56 +00:00
* @return Users
*/
public function setEmail($email)
{
$this->email = $email;
return $this;
}
/**
* Get email
*
2015-01-31 18:09:34 +00:00
* @return string
2015-01-22 16:18:56 +00:00
*/
public function getEmail()
{
return $this->email;
}
2015-01-31 14:14:10 +00:00
/**
* @inheritDoc
*/
public function eraseCredentials()
{
}
/**
* @see \Serializable::serialize()
*/
public function serialize()
{
return serialize(array(
$this->id,
));
}
/**
* @see \Serializable::unserialize()
*/
public function unserialize($serialized)
{
2015-01-31 18:09:34 +00:00
list(
2015-01-31 14:14:10 +00:00
$this->id,
) = unserialize($serialized);
}
public function isEqualTo(UserInterface $user)
{
return $this->username === $user->getUsername();
}
public function isAccountNonExpired()
{
return true;
}
public function isAccountNonLocked()
{
return true;
}
public function isCredentialsNonExpired()
{
return true;
}
public function isEnabled()
{
return $this->isActive;
}
2015-01-22 16:18:56 +00:00
}