src/Entity/AdminUser.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\AdminUserRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  6. use Symfony\Component\Security\Core\User\UserInterface;
  7. /**
  8.  * @ORM\Entity(repositoryClass=AdminUserRepository::class)
  9.  */
  10. class AdminUser implements UserInterfacePasswordAuthenticatedUserInterface
  11. {
  12.     /**
  13.      * @ORM\Id
  14.      * @ORM\GeneratedValue
  15.      * @ORM\Column(type="integer")
  16.      */
  17.     private $id;
  18.     /**
  19.      * @ORM\Column(type="string", length=180, unique=true)
  20.      */
  21.     private $email;
  22.     /**
  23.      * @ORM\Column(type="json")
  24.      */
  25.     private $roles = [];
  26.     /**
  27.      * @var string The hashed password
  28.      * @ORM\Column(type="string")
  29.      */
  30.     private $password;
  31.     public function getId(): ?int
  32.     {
  33.         return $this->id;
  34.     }
  35.     public function getEmail(): ?string
  36.     {
  37.         return $this->email;
  38.     }
  39.     public function setEmail(string $email): self
  40.     {
  41.         $this->email $email;
  42.         return $this;
  43.     }
  44.     /**
  45.      * A visual identifier that represents this user.
  46.      *
  47.      * @see UserInterface
  48.      */
  49.     public function getUserIdentifier(): string
  50.     {
  51.         return (string) $this->email;
  52.     }
  53.     /**
  54.      * @see UserInterface
  55.      */
  56.     public function getRoles(): array
  57.     {
  58.         $roles $this->roles;
  59.         // guarantee every user at least has ROLE_USER
  60.         $roles[] = 'ROLE_USER';
  61.         $roles[] = 'ROLE_ADMIN';
  62.         return array_unique($roles);
  63.     }
  64.     public function setRoles(array $roles): self
  65.     {
  66.         $this->roles $roles;
  67.         return $this;
  68.     }
  69.     /**
  70.      * @see PasswordAuthenticatedUserInterface
  71.      */
  72.     public function getPassword(): string
  73.     {
  74.         return $this->password;
  75.     }
  76.     public function setPassword(string $password): self
  77.     {
  78.         $this->password $password;
  79.         return $this;
  80.     }
  81.     /**
  82.      * @see UserInterface
  83.      */
  84.     public function eraseCredentials()
  85.     {
  86.         // If you store any temporary, sensitive data on the user, clear it here
  87.         // $this->plainPassword = null;
  88.     }
  89. }