src/Entity/User.php line 17

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\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  6. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  7. use Symfony\Component\Security\Core\User\UserInterface;
  8. #[ORM\Entity(repositoryClassUserRepository::class)]
  9. #[ORM\UniqueConstraint(name'UNIQ_IDENTIFIER_EMAIL'fields: ['email'])]
  10. #[ORM\InheritanceType("JOINED")]
  11. #[ORM\DiscriminatorColumn(name"discr"type"string")]
  12. #[ORM\DiscriminatorMap(["user" => "User""chercheur" => "Chercheur""committeemember" => "Committeemember"])]
  13. #[UniqueEntity(fields: ['email'], message'There is already an account with this email')]
  14. class User implements UserInterfacePasswordAuthenticatedUserInterface
  15. {
  16.     #[ORM\Id]
  17.     #[ORM\GeneratedValue]
  18.     #[ORM\Column]
  19.     private ?int $id null;
  20.     #[ORM\Column(length180uniquetrue)]
  21.     private ?string $email null;
  22.     #[ORM\Column]
  23.     private array $roles = [];
  24.     /**
  25.      * @var string The hashed password
  26.      */
  27.     #[ORM\Column]
  28.     private ?string $password null;
  29.     public function getId(): ?int
  30.     {
  31.         return $this->id;
  32.     }
  33.     public function getEmail(): ?string
  34.     {
  35.         return $this->email;
  36.     }
  37.     public function setEmail(string $email): static
  38.     {
  39.         $this->email $email;
  40.         return $this;
  41.     }
  42.     /**
  43.      * A visual identifier that represents this user.
  44.      *
  45.      * @see UserInterface
  46.      */
  47.     public function getUserIdentifier(): string
  48.     {
  49.         return (string) $this->email;
  50.     }
  51.     /**
  52.      * @see UserInterface
  53.      */
  54.     public function getRoles(): array
  55.     {
  56.         $roles $this->roles;
  57.         // guarantee every user at least has ROLE_USER
  58.         $roles[] = 'ROLE_USER';
  59.         return array_unique($roles);
  60.     }
  61.     public function setRoles(array $roles): static
  62.     {
  63.         $this->roles $roles;
  64.         return $this;
  65.     }
  66.     /**
  67.      * @see PasswordAuthenticatedUserInterface
  68.      */
  69.     public function getPassword(): string
  70.     {
  71.         return $this->password;
  72.     }
  73.     public function setPassword(string $password): static
  74.     {
  75.         $this->password $password;
  76.         return $this;
  77.     }
  78.     /**
  79.      * @see UserInterface
  80.      */
  81.     public function eraseCredentials(): void
  82.     {
  83.         // If you store any temporary, sensitive data on the user, clear it here
  84.         // $this->plainPassword = null;
  85.     }
  86. }