Guest User

Untitled

a guest
Feb 10th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.08 KB | None | 0 0
  1. <?php
  2. namespace App\Entity;
  3.  
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Symfony\Component\Validator\Constraints as Assert;
  6. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  7. use Symfony\Component\Security\Core\User\UserInterface;
  8.  
  9. /**
  10.  * @ORM\Entity
  11.  * @UniqueEntity(fields="id", message="id already taken")
  12.  * @UniqueEntity(fields="email", message="Email already taken")
  13.  * @UniqueEntity(fields="username", message="Username already taken")
  14.  */
  15. class User implements UserInterface
  16. {
  17.     /**
  18.      * @ORM\Id
  19.      * @ORM\Column(type="integer")
  20.      * @ORM\GeneratedValue(strategy="AUTO")
  21.      */
  22.     private $id;
  23.  
  24.     /**
  25.      * @ORM\Column(type="string", length=255, unique=true)
  26.      * @Assert\NotBlank()
  27.      * @Assert\Email()
  28.      */
  29.     private $email;
  30.  
  31.     /**
  32.      * @ORM\Column(type="string", length=255, unique=true)
  33.      * @Assert\NotBlank()
  34.      */
  35.     private $username;
  36.  
  37.     /**
  38.      * @Assert\NotBlank()
  39.      * @Assert\Length(max=4096)
  40.      */
  41.     private $plainPassword;
  42.  
  43.     /**
  44.      * The below length depends on the "algorithm" you use for encoding
  45.      * the password, but this works well with bcrypt.
  46.      *
  47.      * @ORM\Column(type="string", length=64)
  48.      */
  49.     private $password;
  50.  
  51.     /**
  52.      * @ORM\Column(type="array")
  53.      */
  54.     private $roles;
  55.  
  56.     /**
  57.      * User constructor.
  58.      */
  59.     public function __construct()
  60.     {
  61.         $this->roles = array('ROLE_USER');
  62.     }
  63.  
  64.     // other properties and methods
  65.  
  66.     /**
  67.      * @return mixed
  68.      */
  69.     public function getId()
  70.     {
  71.         return $this->id;
  72.     }
  73.  
  74.     /**
  75.      * @return mixed
  76.      */
  77.     public function getEmail()
  78.     {
  79.         return $this->email;
  80.     }
  81.  
  82.     /**
  83.      * @param $email
  84.      */
  85.     public function setEmail($email)
  86.     {
  87.         $this->email = $email;
  88.     }
  89.  
  90.     /**
  91.      * @return string
  92.      */
  93.     public function getUsername()
  94.     {
  95.         return $this->username;
  96.     }
  97.  
  98.     /**
  99.      * @param $username
  100.      */
  101.     public function setUsername($username)
  102.     {
  103.         $this->username = $username;
  104.     }
  105.  
  106.     /**
  107.      * @return mixed
  108.      */
  109.     public function getPlainPassword()
  110.     {
  111.         return $this->plainPassword;
  112.     }
  113.  
  114.     /**
  115.      * @param $password
  116.      */
  117.     public function setPlainPassword($password)
  118.     {
  119.         $this->plainPassword = $password;
  120.     }
  121.  
  122.     /**
  123.      * @return string
  124.      */
  125.     public function getPassword()
  126.     {
  127.         return $this->password;
  128.     }
  129.  
  130.     /**
  131.      * @param $password
  132.      */
  133.     public function setPassword($password)
  134.     {
  135.         $this->password = $password;
  136.     }
  137.  
  138.     /**
  139.      * @return string|null
  140.      */
  141.     public function getSalt()
  142.     {
  143.         // The bcrypt and argon2i algorithms don't require a separate salt.
  144.         // You *may* need a real salt if you choose a different encoder.
  145.         return null;
  146.     }
  147.  
  148.     /**
  149.      * @return array
  150.      */
  151.     public function getRoles()
  152.     {
  153.         return $this->roles;
  154.     }
  155.  
  156.     /**
  157.      *
  158.      */
  159.     public function eraseCredentials()
  160.     {
  161.     }
  162. }
Add Comment
Please, Sign In to add comment