Advertisement
Guest User

Untitled

a guest
Nov 24th, 2016
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.05 KB | None | 0 0
  1. <?php
  2.  
  3. namespace AppBundle\Entity;
  4.  
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Symfony\Bridge\Doctrine\Security\User\UserLoaderInterface;
  7. use Symfony\Component\Security\Core\User\UserInterface;
  8. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  9. use Symfony\Component\Validator\Constraints as Assert;
  10.  
  11.  
  12. /**
  13.  * User
  14.  *
  15.  * @ORM\Table(name="user")
  16.  * @ORM\Entity(repositoryClass="AppBundle\Repository\UserRepository")
  17.  * @UniqueEntity(fields="email", message="Email already taken")
  18.  * @UniqueEntity(fields="username",message="Username already taken")
  19.  */
  20. class User implements UserInterface, \Serializable
  21. {
  22.     /**
  23.      * @var int
  24.      *
  25.      * @ORM\Column(name="id", type="integer")
  26.      * @ORM\Id
  27.      * @ORM\GeneratedValue(strategy="AUTO")
  28.      */
  29.     private $id;
  30.  
  31.     /**
  32.      * @ORM\Column(type="string", length=255, unique=true)
  33.      * @Assert\NotBlank()
  34.      * @Assert\Email()
  35.      */
  36.     private $email;
  37.  
  38.     /**
  39.      * @ORM\Column(type="string", length=255, unique=true)
  40.      * @Assert\NotBlank()
  41.     */
  42.     private $username;
  43.  
  44.     /**
  45.      * @Assert\NotBlank()
  46.      * @Assert\Length(max=4096)
  47.      */
  48.     private $plainPassword;
  49.  
  50.     /**
  51.      * @ORM\Column(type="string", length=64)
  52.      *
  53.      */
  54.     private $password;
  55.  
  56.      /** Get id
  57.      *
  58.      * @return int
  59.      */
  60.  
  61.     /**
  62.      * @ORM\Column(name="is_active", type="boolean")
  63.      */
  64.     private $isActive;
  65.  
  66.     public function __construct()
  67.     {
  68.         $this->isActive = true;
  69.         // may not be needed, see section on salt below
  70.         // $this->salt = md5(uniqid(null, true));
  71.     }
  72.  
  73.     public function getId()
  74.     {
  75.         return $this->id;
  76.     }
  77.  
  78.     /**
  79.      * Set email
  80.      *
  81.      * @param string $email
  82.      *
  83.      * @return User
  84.      */
  85.     public function setEmail($email)
  86.     {
  87.         $this->email = $email;
  88.  
  89.         return $this;
  90.     }
  91.  
  92.     /**
  93.      * Get email
  94.      *
  95.      * @return string
  96.      */
  97.     public function getEmail()
  98.     {
  99.         return $this->email;
  100.     }
  101.  
  102.     /**
  103.      * Set username
  104.      *
  105.      * @param string $username
  106.      *
  107.      * @return User
  108.      */
  109.     public function setUsername($username)
  110.     {
  111.         $this->username = $username;
  112.  
  113.         return $this;
  114.     }
  115.  
  116.     /**
  117.      * Get username
  118.      *
  119.      * @return string
  120.      */
  121.     public function getUsername()
  122.     {
  123.         return $this->username;
  124.     }
  125.  
  126.     public function getSalt()
  127.     {
  128.         // you *may* need a real salt depending on your encoder
  129.         // see section on salt below
  130.         return null;
  131.     }
  132.  
  133.     /**
  134.      * Set password
  135.      *
  136.      * @param string $password
  137.      *
  138.      * @return User
  139.      */
  140.     public function setPassword($password)
  141.     {
  142.         $this->password = $password;
  143.  
  144.         return $this;
  145.     }
  146.  
  147.     /**
  148.      * Get password
  149.      *
  150.      * @return string
  151.      */
  152.     public function getPassword()
  153.     {
  154.         return $this->password;
  155.     }
  156.     public function getRoles()
  157.     {
  158.         return array('ROLE_USER');
  159.     }
  160.  
  161.     public function eraseCredentials()
  162.     {
  163.     }
  164.  
  165.     /** @see \Serializable::serialize() */
  166.     public function serialize()
  167.     {
  168.         return serialize(array(
  169.             $this->id,
  170.             $this->username,
  171.             $this->password,
  172.             // see section on salt below
  173.             // $this->salt,
  174.         ));
  175.     }
  176.  
  177.     /** @see \Serializable::unserialize() */
  178.     public function unserialize($serialized)
  179.     {
  180.         list (
  181.             $this->id,
  182.             $this->username,
  183.             $this->password,
  184.             // see section on salt below
  185.             // $this->salt
  186.             ) = unserialize($serialized);
  187.     }
  188.  
  189.     /**
  190.      * Set isActive
  191.      *
  192.      * @param boolean $isActive
  193.      *
  194.      * @return User
  195.      */
  196.     public function setIsActive($isActive)
  197.     {
  198.         $this->isActive = $isActive;
  199.  
  200.         return $this;
  201.     }
  202.  
  203.     /**
  204.      * Get isActive
  205.      *
  206.      * @return boolean
  207.      */
  208.     public function getIsActive()
  209.     {
  210.         return $this->isActive;
  211.     }
  212. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement