yoesoff

User.php

Sep 29th, 2019
279
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.76 KB | None | 0 0
  1. <?php
  2.  
  3. namespace App\Entity;
  4.  
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Symfony\Component\Security\Core\User\UserInterface;
  7.  
  8. /**
  9.  * @ORM\Entity(repositoryClass="App\Repository\UserRepository")
  10.  */
  11. class User implements UserInterface, \Serializable
  12. {
  13.     /**
  14.      * @ORM\Id()
  15.      * @ORM\GeneratedValue()
  16.      * @ORM\Column(type="integer")
  17.      */
  18.     private $id;
  19.  
  20.     /**
  21.      * @ORM\Column(type="string", length=255)
  22.      */
  23.     private $username;
  24.  
  25.     /**
  26.      * @ORM\Column(type="string", length=255)
  27.      */
  28.     private $email;
  29.  
  30.     /**
  31.      * @ORM\Column(type="string", length=255, nullable=true)
  32.      */
  33.     private $password;
  34.  
  35.     /**
  36.      * @ORM\Column(type="text", nullable=true)
  37.      */
  38.     private $address;
  39.  
  40.     public function getId(): ?int
  41.     {
  42.         return $this->id;
  43.     }
  44.  
  45.     public function getUsername(): ?string
  46.     {
  47.         return $this->username;
  48.     }
  49.  
  50.     public function setUsername(string $username): self
  51.     {
  52.         $this->username = $username;
  53.  
  54.         return $this;
  55.     }
  56.  
  57.     public function getEmail(): ?string
  58.     {
  59.         return $this->email;
  60.     }
  61.  
  62.     public function setEmail(string $email): self
  63.     {
  64.         $this->email = $email;
  65.  
  66.         return $this;
  67.     }
  68.  
  69.     public function getPassword(): ?string
  70.     {
  71.         return $this->password;
  72.     }
  73.  
  74.     public function setPassword(?string $password): self
  75.     {
  76.         $this->password = $password;
  77.  
  78.         return $this;
  79.     }
  80.  
  81.     public function getAddress(): ?string
  82.     {
  83.         return $this->address;
  84.     }
  85.  
  86.     public function setAddress(?string $address): self
  87.     {
  88.         $this->address = $address;
  89.  
  90.         return $this;
  91.     }
  92.  
  93.     public function __toString()
  94.     {
  95.         return $this->getUsername();
  96.     }
  97.  
  98.     /** @see \Serializable::serialize() */
  99.     public function serialize()
  100.     {
  101.         return serialize(array(
  102.             $this->id,
  103.             $this->email,
  104.             $this->username,
  105.             $this->password,
  106.             // see section on salt below
  107.             // $this->salt,
  108.         ));
  109.     }
  110.  
  111.     /** @see \Serializable::unserialize() */
  112.     public function unserialize($serialized)
  113.     {
  114.         list (
  115.             $this->id,
  116.             $this->email,
  117.             $this->username,
  118.             $this->password,
  119.             // see section on salt below
  120.             // $this->salt
  121.         ) = unserialize($serialized, array('allowed_classes' => false));
  122.     }
  123.  
  124.     public function getSalt()
  125.     {
  126.         // you *may* need a real salt depending on your encoder
  127.         // see section on salt below
  128.         return null;
  129.     }
  130.  
  131.     public function getRoles()
  132.     {
  133.         return array('ROLE_USER');
  134.     }
  135.  
  136.     public function eraseCredentials()
  137.     {
  138.     }
  139. }
Advertisement
Add Comment
Please, Sign In to add comment