Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace AppBundle\Entity;
- use Doctrine\ORM\Mapping as ORM;
- use Symfony\Bridge\Doctrine\Security\User\UserLoaderInterface;
- use Symfony\Component\Security\Core\User\UserInterface;
- use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
- use Symfony\Component\Validator\Constraints as Assert;
- /**
- * User
- *
- * @ORM\Table(name="user")
- * @ORM\Entity(repositoryClass="AppBundle\Repository\UserRepository")
- * @UniqueEntity(fields="email", message="Email already taken")
- * @UniqueEntity(fields="username",message="Username already taken")
- */
- class User implements UserInterface, \Serializable
- {
- /**
- * @var int
- *
- * @ORM\Column(name="id", type="integer")
- * @ORM\Id
- * @ORM\GeneratedValue(strategy="AUTO")
- */
- private $id;
- /**
- * @ORM\Column(type="string", length=255, unique=true)
- * @Assert\NotBlank()
- * @Assert\Email()
- */
- private $email;
- /**
- * @ORM\Column(type="string", length=255, unique=true)
- * @Assert\NotBlank()
- */
- private $username;
- /**
- * @Assert\NotBlank()
- * @Assert\Length(max=4096)
- */
- private $plainPassword;
- /**
- * @ORM\Column(type="string", length=64)
- *
- */
- private $password;
- /** Get id
- *
- * @return int
- */
- /**
- * @ORM\Column(name="is_active", type="boolean")
- */
- private $isActive;
- public function __construct()
- {
- $this->isActive = true;
- // may not be needed, see section on salt below
- // $this->salt = md5(uniqid(null, true));
- }
- public function getId()
- {
- return $this->id;
- }
- /**
- * Set email
- *
- * @param string $email
- *
- * @return User
- */
- public function setEmail($email)
- {
- $this->email = $email;
- return $this;
- }
- /**
- * Get email
- *
- * @return string
- */
- public function getEmail()
- {
- return $this->email;
- }
- /**
- * Set username
- *
- * @param string $username
- *
- * @return User
- */
- public function setUsername($username)
- {
- $this->username = $username;
- return $this;
- }
- /**
- * Get username
- *
- * @return string
- */
- public function getUsername()
- {
- return $this->username;
- }
- public function getSalt()
- {
- // you *may* need a real salt depending on your encoder
- // see section on salt below
- return null;
- }
- /**
- * Set password
- *
- * @param string $password
- *
- * @return User
- */
- public function setPassword($password)
- {
- $this->password = $password;
- return $this;
- }
- /**
- * Get password
- *
- * @return string
- */
- public function getPassword()
- {
- return $this->password;
- }
- public function getRoles()
- {
- return array('ROLE_USER');
- }
- public function eraseCredentials()
- {
- }
- /** @see \Serializable::serialize() */
- public function serialize()
- {
- return serialize(array(
- $this->id,
- $this->username,
- $this->password,
- // see section on salt below
- // $this->salt,
- ));
- }
- /** @see \Serializable::unserialize() */
- public function unserialize($serialized)
- {
- list (
- $this->id,
- $this->username,
- $this->password,
- // see section on salt below
- // $this->salt
- ) = unserialize($serialized);
- }
- /**
- * Set isActive
- *
- * @param boolean $isActive
- *
- * @return User
- */
- public function setIsActive($isActive)
- {
- $this->isActive = $isActive;
- return $this;
- }
- /**
- * Get isActive
- *
- * @return boolean
- */
- public function getIsActive()
- {
- return $this->isActive;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement