<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use App\Repository\UtilisateurRepository;
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\ArrayCollection;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
// #[ORM\Entity(repositoryClass: UtilisateurRepository::class)]
// #[ORM\Table(name: '`utilisateur`')]
/**
* @ORM\Entity(repositoryClass=UtilisateurRepository::class)
*/
class Utilisateur implements UserInterface, PasswordAuthenticatedUserInterface
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255, unique=true)
*/
private $utl_username;
/**
* @var string The hashed password
* @ORM\Column(type="string", length=255)
*/
private $utl_password;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $utl_salt;
/**
* @ORM\Column(type="boolean")
*/
private $utl_prestataire;
/**
* @ORM\Column(type="string", length=255)
*/
private $utl_nom;
/**
* @ORM\Column(type="string", length=255)
*/
private $utl_prenom;
/**
* @ORM\Column(type="boolean")
*/
private $utl_is_masked;
/**
* @ORM\Column(type="string", length=255, nullable=true, unique=true)
*/
private $utl_agrement;
/**
* @ORM\OneToMany(targetEntity=Rendezvous::class, mappedBy="utilisateur", cascade = {"persist"})
*/
private $rendezVouses;
/**
* @ORM\OneToMany(targetEntity=UtilisateurInfo::class, mappedBy="utl_inf_utilisateur", orphanRemoval=false, fetch="EAGER")
*/
private $utilisateurInfos;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $id_old;
/**
* @ORM\Column(type="json")
*/
private $roles = [];
/**
* @ORM\ManyToOne(targetEntity=CentreGroupe::class, inversedBy="utilisateurs")
* @ORM\JoinColumn(nullable=true)
*/
private $CentreGroupe;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $utl_email;
public function __construct()
{
$this->rendezVouses = new ArrayCollection();
$this->utilisateurInfos = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getUtlUsername(): ?string
{
return $this->utl_username;
}
public function setUtlUsername(string $utl_username): self
{
$this->utl_username = $utl_username;
return $this;
}
public function getUtlPassword(): ?string
{
return null;
}
public function setUtlPassword(string $utl_password): self
{
$this->utl_password = $utl_password;
return $this;
}
public function getUtlSalt(): ?string
{
return $this->utl_salt;
}
public function setUtlSalt(string $utl_salt): self
{
$this->utl_salt = $utl_salt;
return $this;
}
public function isUtlPrestataire(): ?bool
{
return $this->utl_prestataire;
}
public function setUtlPrestataire(bool $utl_prestataire): self
{
$this->utl_prestataire = $utl_prestataire;
return $this;
}
public function getUtlNom(): ?string
{
return $this->utl_nom;
}
public function setUtlNom(string $utl_nom): self
{
$this->utl_nom = $utl_nom;
return $this;
}
public function getUtlPrenom(): ?string
{
return $this->utl_prenom;
}
public function setUtlPrenom(string $utl_prenom): self
{
$this->utl_prenom = $utl_prenom;
return $this;
}
public function isUtlIsMasked(): ?bool
{
return $this->utl_is_masked;
}
public function setUtlIsMasked(bool $utl_is_masked): self
{
$this->utl_is_masked = $utl_is_masked;
return $this;
}
public function getUtlAgrement(): ?string
{
return $this->utl_agrement;
}
public function setUtlAgrement(?string $utl_agrement): self
{
$this->utl_agrement = $utl_agrement;
return $this;
}
/**
* @return Collection<int, Rendezvous>
*/
public function getRendezVouses(): Collection
{
return $this->rendezVouses;
}
public function addRendezVouse(Rendezvous $rendezVouse): self
{
if (!$this->rendezVouses->contains($rendezVouse)) {
$this->rendezVouses[] = $rendezVouse;
$rendezVouse->setUtilisateur($this);
}
return $this;
}
public function removeRendezVouse(Rendezvous $rendezVouse): self
{
if ($this->rendezVouses->removeElement($rendezVouse)) {
// set the owning side to null (unless already changed)
if ($rendezVouse->getUtilisateur() === $this) {
$rendezVouse->setUtilisateur(null);
}
}
return $this;
}
/**
* @return Collection<int, UtilisateurInfo>
*/
public function getUtilisateurInfos(): Collection
{
return $this->utilisateurInfos;
}
public function addUtilisateurInfo(UtilisateurInfo $utilisateurInfo): self
{
if (!$this->utilisateurInfos->contains($utilisateurInfo)) {
$this->utilisateurInfos[] = $utilisateurInfo;
$utilisateurInfo->setUtlInfUtilisateur($this);
}
return $this;
}
public function removeUtilisateurInfo(UtilisateurInfo $utilisateurInfo): self
{
if ($this->utilisateurInfos->removeElement($utilisateurInfo)) {
// set the owning side to null (unless already changed)
if ($utilisateurInfo->getUtlInfUtilisateur() === $this) {
$utilisateurInfo->setUtlInfUtilisateur(null);
}
}
return $this;
}
public function getIdOld(): ?int
{
return $this->id_old;
}
public function setIdOld(int $id_old): self
{
$this->id_old = $id_old;
return $this;
}
// Partie Authentification
public function getRoles(): array
{
$roles = $this->roles;
// we need to make sure to have at least one role
if (empty($roles)) {
$roles[] = 'ROLE_ADMIN';
}
return array_unique($roles);
}
public function setRoles(array $roles): self
{
$this->roles = $roles;
return $this;
}
public function getPassword(): string
{
return $this->utl_password;
}
public function setPassword(string $utl_password): self
{
$this->utl_password = $utl_password;
return $this;
}
public function getSalt()
{
// on ne va pas utiliser de sel (salt) car on utilise bcrypt pour le hashage du mot de passe
// bcrypt inclus déjà un sel aléatoire
return null;
}
public function getUsername()
{
return $this->utl_username; // retourne le nom de l'utilisateur comme identifiant
}
public function getUserIdentifier()
{
return $this->utl_username;
}
public function eraseCredentials()
{
// rien à faire ici, car on ne stocke pas les mots de passe en clair
// si vous stockez les mots de passe en clair, vous devriez les effacer ici
}
public function getCentreGroupe(): ?CentreGroupe
{
return $this->CentreGroupe;
}
public function setCentreGroupe(?CentreGroupe $CentreGroupe): self
{
$this->CentreGroupe = $CentreGroupe;
return $this;
}
public function getUtlEmail(): ?string
{
return $this->utl_email;
}
public function setUtlEmail(?string $utl_email): self
{
$this->utl_email = $utl_email;
return $this;
}
}