src/Entity/Utilisateur.php line 19

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use App\Repository\UtilisateurRepository;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Symfony\Component\Security\Core\User\UserInterface;
  8. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  9. // #[ORM\Entity(repositoryClass: UtilisateurRepository::class)]
  10. // #[ORM\Table(name: '`utilisateur`')]
  11. /**
  12.  * @ORM\Entity(repositoryClass=UtilisateurRepository::class)
  13.  */
  14. class Utilisateur implements UserInterfacePasswordAuthenticatedUserInterface
  15. {
  16.     /**
  17.      * @ORM\Id
  18.      * @ORM\GeneratedValue
  19.      * @ORM\Column(type="integer")
  20.      */
  21.     private $id;
  22.     /**
  23.      * @ORM\Column(type="string", length=255,  unique=true)
  24.      */
  25.     private $utl_username;
  26.     /**
  27.      * @var string The hashed password
  28.      * @ORM\Column(type="string", length=255)
  29.      */
  30.     private $utl_password;
  31.     /**
  32.      * @ORM\Column(type="string", length=255, nullable=true)
  33.      */
  34.     private $utl_salt;
  35.     /**
  36.      * @ORM\Column(type="boolean")
  37.      */
  38.     private $utl_prestataire;
  39.     /**
  40.      * @ORM\Column(type="string", length=255)
  41.      */
  42.     private $utl_nom;
  43.     /**
  44.      * @ORM\Column(type="string", length=255)
  45.      */
  46.     private $utl_prenom;
  47.     /**
  48.      * @ORM\Column(type="boolean")
  49.      */
  50.     private $utl_is_masked;
  51.     /**
  52.      * @ORM\Column(type="string", length=255, nullable=true,  unique=true)
  53.      */
  54.     private $utl_agrement;
  55.     /**
  56.      * @ORM\OneToMany(targetEntity=Rendezvous::class, mappedBy="utilisateur", cascade = {"persist"})
  57.      */
  58.     private $rendezVouses;
  59.     /**
  60.      * @ORM\OneToMany(targetEntity=UtilisateurInfo::class, mappedBy="utl_inf_utilisateur", orphanRemoval=false, fetch="EAGER")
  61.      */
  62.     private $utilisateurInfos;
  63.     /**
  64.      * @ORM\Column(type="integer", nullable=true)
  65.      */
  66.     private $id_old;
  67.     /**
  68.      * @ORM\Column(type="json")
  69.      */
  70.     private $roles = [];
  71.     /**
  72.      * @ORM\ManyToOne(targetEntity=CentreGroupe::class, inversedBy="utilisateurs")
  73.      * @ORM\JoinColumn(nullable=true)
  74.      */
  75.     private $CentreGroupe;
  76.     /**
  77.      * @ORM\Column(type="string", length=255, nullable=true)
  78.      */
  79.     private $utl_email;
  80.     public function __construct()
  81.     {
  82.         $this->rendezVouses = new ArrayCollection();
  83.         $this->utilisateurInfos = new ArrayCollection();
  84.     }
  85.     public function getId(): ?int
  86.     {
  87.         return $this->id;
  88.     }
  89.     public function getUtlUsername(): ?string
  90.     {
  91.         return $this->utl_username;
  92.     }
  93.     public function setUtlUsername(string $utl_username): self
  94.     {
  95.         $this->utl_username $utl_username;
  96.         return $this;
  97.     }
  98.     public function getUtlPassword(): ?string
  99.     {
  100.         return null;
  101.     }
  102.     public function setUtlPassword(string $utl_password): self
  103.     {
  104.         $this->utl_password $utl_password;
  105.         return $this;
  106.     }
  107.     public function getUtlSalt(): ?string
  108.     {
  109.         return $this->utl_salt;
  110.     }
  111.     public function setUtlSalt(string $utl_salt): self
  112.     {
  113.         $this->utl_salt $utl_salt;
  114.         return $this;
  115.     }
  116.     public function isUtlPrestataire(): ?bool
  117.     {
  118.         return $this->utl_prestataire;
  119.     }
  120.     public function setUtlPrestataire(bool $utl_prestataire): self
  121.     {
  122.         $this->utl_prestataire $utl_prestataire;
  123.         return $this;
  124.     }
  125.     public function getUtlNom(): ?string
  126.     {
  127.         return $this->utl_nom;
  128.     }
  129.     public function setUtlNom(string $utl_nom): self
  130.     {
  131.         $this->utl_nom $utl_nom;
  132.         return $this;
  133.     }
  134.     public function getUtlPrenom(): ?string
  135.     {
  136.         return $this->utl_prenom;
  137.     }
  138.     public function setUtlPrenom(string $utl_prenom): self
  139.     {
  140.         $this->utl_prenom $utl_prenom;
  141.         return $this;
  142.     }
  143.     public function isUtlIsMasked(): ?bool
  144.     {
  145.         return $this->utl_is_masked;
  146.     }
  147.     public function setUtlIsMasked(bool $utl_is_masked): self
  148.     {
  149.         $this->utl_is_masked $utl_is_masked;
  150.         return $this;
  151.     }
  152.     public function getUtlAgrement(): ?string
  153.     {
  154.         return $this->utl_agrement;
  155.     }
  156.     public function setUtlAgrement(?string $utl_agrement): self
  157.     {
  158.         $this->utl_agrement $utl_agrement;
  159.         return $this;
  160.     }
  161.     /**
  162.      * @return Collection<int, Rendezvous>
  163.      */
  164.     public function getRendezVouses(): Collection
  165.     {
  166.         return $this->rendezVouses;
  167.     }
  168.     public function addRendezVouse(Rendezvous $rendezVouse): self
  169.     {
  170.         if (!$this->rendezVouses->contains($rendezVouse)) {
  171.             $this->rendezVouses[] = $rendezVouse;
  172.             $rendezVouse->setUtilisateur($this);
  173.         }
  174.         return $this;
  175.     }
  176.     public function removeRendezVouse(Rendezvous $rendezVouse): self
  177.     {
  178.         if ($this->rendezVouses->removeElement($rendezVouse)) {
  179.             // set the owning side to null (unless already changed)
  180.             if ($rendezVouse->getUtilisateur() === $this) {
  181.                 $rendezVouse->setUtilisateur(null);
  182.             }
  183.         }
  184.         return $this;
  185.     }
  186.     /**
  187.      * @return Collection<int, UtilisateurInfo>
  188.      */
  189.     public function getUtilisateurInfos(): Collection
  190.     {
  191.         return $this->utilisateurInfos;
  192.     }
  193.     public function addUtilisateurInfo(UtilisateurInfo $utilisateurInfo): self
  194.     {
  195.         if (!$this->utilisateurInfos->contains($utilisateurInfo)) {
  196.             $this->utilisateurInfos[] = $utilisateurInfo;
  197.             $utilisateurInfo->setUtlInfUtilisateur($this);
  198.         }
  199.         return $this;
  200.     }
  201.     public function removeUtilisateurInfo(UtilisateurInfo $utilisateurInfo): self
  202.     {
  203.         if ($this->utilisateurInfos->removeElement($utilisateurInfo)) {
  204.             // set the owning side to null (unless already changed)
  205.             if ($utilisateurInfo->getUtlInfUtilisateur() === $this) {
  206.                 $utilisateurInfo->setUtlInfUtilisateur(null);
  207.             }
  208.         }
  209.         return $this;
  210.     }
  211.     public function getIdOld(): ?int
  212.     {
  213.         return $this->id_old;
  214.     }
  215.     public function setIdOld(int $id_old): self
  216.     {
  217.         $this->id_old $id_old;
  218.         return $this;
  219.     }
  220.     // Partie Authentification
  221.     public function getRoles(): array
  222.     {
  223.         $roles $this->roles;
  224.         // we need to make sure to have at least one role
  225.         if (empty($roles)) {
  226.             $roles[] = 'ROLE_ADMIN';
  227.         }
  228.         return array_unique($roles);
  229.     }
  230.     public function setRoles(array $roles): self
  231.     {
  232.         $this->roles $roles;
  233.         return $this;
  234.     }
  235.     public function getPassword(): string
  236.     {
  237.         return $this->utl_password;
  238.     }
  239.     public function setPassword(string $utl_password): self
  240.     {
  241.         $this->utl_password $utl_password;
  242.         return $this;
  243.     }
  244.     public function getSalt()
  245.     {
  246.         // on ne va pas utiliser de sel (salt) car on utilise bcrypt pour le hashage du mot de passe
  247.         // bcrypt inclus déjà un sel aléatoire
  248.         return null;
  249.     }
  250.     public function getUsername()
  251.     {
  252.         return $this->utl_username// retourne le nom de l'utilisateur comme identifiant
  253.     }
  254.     public function getUserIdentifier()
  255.     {
  256.         return $this->utl_username;
  257.     }
  258.     public function eraseCredentials()
  259.     {
  260.         // rien à faire ici, car on ne stocke pas les mots de passe en clair
  261.         // si vous stockez les mots de passe en clair, vous devriez les effacer ici
  262.     }
  263.     public function getCentreGroupe(): ?CentreGroupe
  264.     {
  265.         return $this->CentreGroupe;
  266.     }
  267.     public function setCentreGroupe(?CentreGroupe $CentreGroupe): self
  268.     {
  269.         $this->CentreGroupe $CentreGroupe;
  270.         return $this;
  271.     }
  272.     public function getUtlEmail(): ?string
  273.     {
  274.         return $this->utl_email;
  275.     }
  276.     public function setUtlEmail(?string $utl_email): self
  277.     {
  278.         $this->utl_email $utl_email;
  279.         return $this;
  280.     }
  281. }