src/Entity/User.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use DateTimeImmutable;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use App\Repository\UserRepository;
  6. use Symfony\Component\Validator\Constraints as Assert;
  7. use Symfony\Component\Security\Core\User\UserInterface;
  8. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  9. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  10. #[UniqueEntity('email')]
  11. #[ORM\Entity(repositoryClassUserRepository::class)]
  12. #[ORM\EntityListeners(['App\EntityListener\UserListener'])]
  13. class User implements UserInterfacePasswordAuthenticatedUserInterface
  14. {
  15.     #[ORM\Id]
  16.     #[ORM\GeneratedValue]
  17.     #[ORM\Column]
  18.     private ?int $id null;
  19.     #[ORM\Column(length180uniquetrue)]
  20.     private ?string $email null;
  21.     #[ORM\Column]
  22.     private array $roles = [];
  23.     /**
  24.      * @var string The hashed password
  25.      */
  26.     #[ORM\Column]
  27.     #[Assert\NotNull()]
  28.     private ?string $password 'password';
  29.     private ?string $plainPassword =null;
  30.     private ?string $newPassword =null;
  31.     #[ORM\Column]
  32.     private ?\DateTimeImmutable $updatedAt null;
  33.     public function __construct()
  34.     {
  35.         $this->updatedAt = new DateTimeImmutable();
  36.     }
  37.     
  38.     public function getId(): ?int
  39.     {
  40.         return $this->id;
  41.     }
  42.     public function getEmail(): ?string
  43.     {
  44.         return $this->email;
  45.     }
  46.     public function setEmail(string $email): static
  47.     {
  48.         $this->email $email;
  49.         return $this;
  50.     }
  51.     /**
  52.      * A visual identifier that represents this user.
  53.      *
  54.      * @see UserInterface
  55.      */
  56.     public function getUserIdentifier(): string
  57.     {
  58.         return (string) $this->email;
  59.     }
  60.     /**
  61.      * @see UserInterface
  62.      */
  63.     public function getRoles(): array
  64.     {
  65.         $roles $this->roles;
  66.         // guarantee every user at least has ROLE_USER
  67.         $roles[] = 'ROLE_USER';
  68.         return array_unique($roles);
  69.     }
  70.     public function setRoles(array $roles): static
  71.     {
  72.         $this->roles $roles;
  73.         return $this;
  74.     }
  75.     /**
  76.      * @see PasswordAuthenticatedUserInterface
  77.      */
  78.     public function getPassword(): string
  79.     {
  80.         return $this->password;
  81.     }
  82.     public function setPassword(string $password): static
  83.     {
  84.         $this->password $password;
  85.         return $this;
  86.     }
  87.     /**
  88.      * @see UserInterface
  89.      */
  90.     public function eraseCredentials(): void
  91.     {
  92.         // If you store any temporary, sensitive data on the user, clear it here
  93.         // $this->plainPassword = null;
  94.     }
  95.     /**
  96.      * Get the value of pleinPassword
  97.      */ 
  98.     public function getPlainPassword()
  99.     {
  100.         return $this->plainPassword;
  101.     }
  102.     /**
  103.      * Set the value of pleinPassword
  104.      *
  105.      * @return  self
  106.      */ 
  107.     public function setPlainPassword($plainPassword)
  108.     {
  109.         $this->plainPassword $plainPassword;
  110.         return $this;
  111.     }
  112.     /**
  113.      * Get the value of newPassword
  114.      */ 
  115.     public function getNewPassword()
  116.     {
  117.         return $this->newPassword;
  118.     }
  119.     /**
  120.      * Set the value of newPassword
  121.      *
  122.      * @return  self
  123.      */ 
  124.     public function setNewPassword($newPassword)
  125.     {
  126.         $this->newPassword $newPassword;
  127.         return $this;
  128.     }
  129.     /**
  130.      * Get the value of updatedAt
  131.      */ 
  132.     public function getUpdatedAt()
  133.     {
  134.         return $this->updatedAt;
  135.     }
  136.     /**
  137.      * Set the value of updatedAt
  138.      *
  139.      * @return  self
  140.      */ 
  141.     public function setUpdatedAt($updatedAt)
  142.     {
  143.         $this->updatedAt $updatedAt;
  144.         return $this;
  145.     }
  146. }