src/Entity/User.php line 11

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