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]
  13.     private ?int $id null;
  14.     #[ORM\Column(length180uniquetrue)]
  15.     private ?string $email null;
  16.     #[ORM\Column]
  17.     private array $roles = [];
  18.     /**
  19.      * @var string The hashed password
  20.      */
  21.     #[ORM\Column]
  22.     private ?string $password null;
  23.     public function getId(): ?int
  24.     {
  25.         return $this->id;
  26.     }
  27.     public function getEmail(): ?string
  28.     {
  29.         return $this->email;
  30.     }
  31.     public function setEmail(string $email): static
  32.     {
  33.         $this->email $email;
  34.         return $this;
  35.     }
  36.     /**
  37.      * A visual identifier that represents this user.
  38.      *
  39.      * @see UserInterface
  40.      */
  41.     public function getUserIdentifier(): string
  42.     {
  43.         return (string) $this->email;
  44.     }
  45.     /**
  46.      * @see UserInterface
  47.      */
  48.     public function getRoles(): array
  49.     {
  50.         $roles $this->roles;
  51.         // guarantee every user at least has ROLE_USER
  52.         $roles[] = 'ROLE_USER';
  53.         return array_unique($roles);
  54.     }
  55.     public function setRoles(array $roles): static
  56.     {
  57.         $this->roles $roles;
  58.         return $this;
  59.     }
  60.     /**
  61.      * @see PasswordAuthenticatedUserInterface
  62.      */
  63.     public function getPassword(): string
  64.     {
  65.         return $this->password;
  66.     }
  67.     public function setPassword(string $password): static
  68.     {
  69.         $this->password $password;
  70.         return $this;
  71.     }
  72.     /**
  73.      * @see UserInterface
  74.      */
  75.     public function eraseCredentials(): void
  76.     {
  77.         // If you store any temporary, sensitive data on the user, clear it here
  78.         // $this->plainPassword = null;
  79.     }
  80. }