src/Entity/Admin.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\AdminRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
  6. use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
  7. use Symfony\Component\Security\Core\User\UserInterface;
  8. /**
  9.  * @ORM\Entity(repositoryClass=AdminRepository::class)
  10.  */
  11. class Admin implements UserInterface
  12. {
  13.     /**
  14.      * @ORM\Id()
  15.      * @ORM\GeneratedValue()
  16.      * @ORM\Column(type="integer")
  17.      */
  18.     private $id;
  19.     /**
  20.      * @ORM\Column(type="string", length=255, nullable=true)
  21.      */
  22.     private $username;
  23.     /**
  24.      * @ORM\Column(type="string", length=255, nullable=true)
  25.      */
  26.     private $email;
  27.     /**
  28.      * @var string
  29.      *
  30.      * @ORM\Column(name="role", type="string", length=255)
  31.      */
  32.     private $role;
  33.     /**
  34.      * @ORM\Column(type="string", length=255)
  35.      */
  36.     private $password;
  37.     /**
  38.      * @var \DateTime
  39.      *
  40.      * @ORM\Column(name="created", type="datetime", nullable=true)
  41.      */
  42.     private $created;
  43.     private $plainPassword;
  44.     public function getPlainPassword()
  45.     {
  46.         return $this->plainPassword;
  47.     }
  48.     public function __construct()
  49.     {
  50.         $this->created = new \DateTime();
  51.         $this->active 1;
  52.         $this->role 'ROLE_SUPER_ADMIN';
  53.     }
  54.     public function setPlainPassword($password)
  55.     {
  56.         $this->plainPassword $password;
  57.         // Si vous modifiez le mot de passe en clair, le mot de passe haché doit également être modifié
  58.         $this->password null;
  59.     }
  60.     /**
  61.      * @var int
  62.      *
  63.      * @ORM\Column(name="active", type="integer", nullable=true)
  64.      */
  65.     private $active;
  66.     public function getId(): ?int
  67.     {
  68.         return $this->id;
  69.     }
  70.     public function __toString()
  71.     {
  72.         return $this->getUsername();
  73.     }
  74.     public function getUsername(): ?string
  75.     {
  76.         return $this->username;
  77.     }
  78.     public function setUsername(?string $username): self
  79.     {
  80.         $this->username $username;
  81.         return $this;
  82.     }
  83.     public function getEmail(): ?string
  84.     {
  85.         return $this->email;
  86.     }
  87.     public function setEmail(?string $email): self
  88.     {
  89.         $this->email $email;
  90.         return $this;
  91.     }
  92.     public function getPassword(): ?string
  93.     {
  94.         return $this->password;
  95.     }
  96.     public function setPassword(string $password): self
  97.     {
  98.         $this->password $password;
  99.         return $this;
  100.     }
  101.     /**
  102.      * @param integer $active
  103.      */
  104.     public function setActive($active)
  105.     {
  106.         $this->active $active;
  107.     }
  108.     /**
  109.      * Get active
  110.      *
  111.      * @return integer
  112.      */
  113.     public function getActive()
  114.     {
  115.         return $this->active;
  116.     }
  117.     /**
  118.      * @return string
  119.      */
  120.     public function getRole(): ?string
  121.     {
  122.         return $this->role;
  123.     }
  124.     /**
  125.      * {@inheritdoc}
  126.      */
  127.     public function getRoles(): array
  128.     {
  129.         return [$this->role];
  130.     }
  131.     /**
  132.      * @param string $role
  133.      */
  134.     public function setRole(string $role): void
  135.     {
  136.         $this->role $role;
  137.     }
  138.     /**
  139.      * @param \DateTime|null $creadted
  140.      */
  141.     public function setCreated(?\DateTime $creadted): void
  142.     {
  143.         $this->created $creadted;
  144.     }
  145.     /**
  146.      * @return \DateTime|null
  147.      */
  148.     public function getCreated(): ?\DateTime
  149.     {
  150.         return $this->created;
  151.     }
  152.     /**
  153.      * Loads the user for the given username.
  154.      *
  155.      * @param string $username The username
  156.      *
  157.      * @return UserInterface
  158.      *
  159.      * @throws UsernameNotFoundException if the user is not found
  160.      */
  161.     public function loadUserByUsername($username)
  162.     {
  163.         // TODO: Implement loadUserByUsername() method.
  164.     }
  165.     /**
  166.      * Refreshes the user for the account interface.
  167.      *
  168.      * @param UserInterface $user
  169.      *
  170.      * @return UserInterface
  171.      *
  172.      * @throws UnsupportedUserException if the account is not supported
  173.      */
  174.     public function refreshUser(UserInterface $user)
  175.     {
  176.         // TODO: Implement refreshUser() method.
  177.     }
  178.     /**
  179.      * @param string $class
  180.      *
  181.      * @return bool
  182.      */
  183.     public function supportsClass($class)
  184.     {
  185.         // TODO: Implement supportsClass() method.
  186.     }
  187.     /**
  188.      * @return null
  189.      */
  190.     public function getSalt()
  191.     {
  192.         return null;
  193.     }
  194.     public function eraseCredentials() {}
  195. }