<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
use Symfony\Component\Security\Core\User\UserInterface;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
/**
* Utilisateur
*
* @ORM\Table(name="utilisateur")
* @ORM\Entity
*/
class Utilisateur implements UserInterface, PasswordAuthenticatedUserInterface, \Serializable
{
/**
* @var int
*
* @ORM\Column(name="id", type="integer", nullable=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @var bool
*
* @ORM\Column(name="sexe", type="boolean", nullable=false, options={"default"="1"})
*/
private $sexe = '1';
/**
* @var string|null
*
* @ORM\Column(name="nom", type="string", length=100, nullable=true)
*/
private $nom;
/**
* @var string|null
*
* @ORM\Column(name="prenom", type="string", length=100, nullable=true)
*/
private $prenom;
/**
* @var string|null
*
* @ORM\Column(name="email", type="string", length=255, nullable=true)
*/
private $email;
/**
* @var string|null
*
* @ORM\Column(name="login", type="string", length=100, nullable=true)
*/
private $login;
/**
* @var string|null
*
* @ORM\Column(name="motdepasse", type="string", length=255, nullable=true)
*/
private $motdepasse;
/**
* @var string|null
* @ORM\Column(name="keycloak_sub", type="string", length=36, nullable=true)
*/
private $keycloakSub;
/**
* @var bool
*
* @ORM\Column(name="etat", type="boolean", nullable=false, options={"default"="1"})
*/
private $etat = '1';
/**
* @var bool
*
* @ORM\Column(name="webservice", type="boolean", nullable=false, options={"default"="1"})
*/
// Colonne gardée en base mais plus utilisée ; mappée pour que les INSERT écrivent 0 (défaut SQL = 1).
private $webservice = '0';
/**
* @var \Doctrine\Common\Collections\Collection
*
* @ORM\OneToMany(targetEntity="Token", mappedBy="utilisateur", cascade={"persist"})
*/
private $tokens;
/**
* @var bool
*
* @ORM\Column(name="DroitValidation", type="boolean", nullable=false, options={"default"="1"})
*/
private $droitValidation= '1';
/**
* @var bool
*
* @ORM\Column(name="DroitModificationListe", type="boolean", nullable=false, options={"default"="0"})
*/
private $droitModificationListe= '0';
/**
* @var bool
*
* @ORM\Column(name="DroitModificationListeException", type="boolean", nullable=false, options={"default"="0"})
*/
private $droitModificationListeException= '0';
/**
* @var bool
*
* @ORM\Column(name="DroitAdmin", type="boolean", nullable=false, options={"default"="0"})
*/
private $droitAdmin= '0';
/**
* @var bool
*
* @ORM\Column(name="DroitMenuParametre", type="boolean", nullable=false, options={"default"="1"})
*/
private $droitMenuParametre= '1';
/**
* @var bool
*
* @ORM\Column(name="DroitMenuListe", type="boolean", nullable=false, options={"default"="1"})
*/
private $droitMenuListe= '1';
/**
* @var bool
*
* @ORM\Column(name="DroitMenuConventionCollective", type="boolean", nullable=false, options={"default"="1"})
*/
private $droitMenuConventionCollective= '1';
/**
* @var bool
*
* @ORM\Column(name="DroitMenuExport", type="boolean", nullable=false, options={"default"="1"})
*/
private $droitMenuExport= '1';
/**
* @var bool
*
* @ORM\Column(name="DroitMenuCalcul", type="boolean", nullable=false, options={"default"="0"})
*/
private $droitMenuCalcul= '0';
/**
* @var bool
*
* @ORM\Column(name="DroitMenuRegle", type="boolean", nullable=false, options={"default"="0"})
*/
private $droitMenuRegle= '0';
/**
* @var bool
*
* @ORM\Column(name="DroitModificationRegleAvance", type="boolean", nullable=false, options={"default"="0"})
*/
private $droitModificationRegleAvance= '0';
public function __construct() {
$this->tokens=new ArrayCollection();
}
public function getUserIdentifier()
{
return $this->id;
}
public function getId(): ?int
{
return $this->id;
}
public function getSexe(): ?bool
{
return $this->sexe;
}
public function setSexe(bool $sexe): self
{
$this->sexe = $sexe;
return $this;
}
public function getNom(): ?string
{
return $this->nom;
}
public function setNom(?string $nom): self
{
$this->nom = $nom;
return $this;
}
public function getPrenom(): ?string
{
return $this->prenom;
}
public function setPrenom(?string $prenom): self
{
$this->prenom = $prenom;
return $this;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(?string $email): self
{
$this->email = $email;
return $this;
}
public function getLogin(): ?string
{
return $this->login;
}
public function setLogin(?string $login): self
{
$this->login = $login;
return $this;
}
public function getMotdepasse(): ?string
{
return $this->motdepasse;
}
public function setMotdepasse(?string $motdepasse): self
{
$this->motdepasse = $motdepasse;
return $this;
}
public function getKeycloakSub(): ?string
{
return $this->keycloakSub;
}
public function setKeycloakSub(?string $keycloakSub): self
{
$this->keycloakSub = $keycloakSub;
return $this;
}
public function getEtat(): ?bool
{
return $this->etat;
}
public function setEtat(bool $etat): self
{
$this->etat = $etat;
return $this;
}
public function getDroitValidation(): ?bool
{
return $this->droitValidation;
}
public function setDroitValidation(bool $droitValidation): self
{
$this->droitValidation = $droitValidation;
return $this;
}
public function getDroitModificationListe(): ?bool
{
return $this->droitModificationListe;
}
public function setDroitModificationListe(bool $droitModificationListe): self
{
$this->droitModificationListe = $droitModificationListe;
return $this;
}
public function getDroitModificationListeException(): ?bool
{
return $this->droitModificationListeException;
}
public function setDroitModificationListeException(bool $droitModificationListeException): self
{
$this->droitModificationListeException = $droitModificationListeException;
return $this;
}
public function getDroitAdmin(): ?bool
{
return $this->droitAdmin;
}
public function setDroitAdmin(bool $droitAdmin): self
{
$this->droitAdmin = $droitAdmin;
return $this;
}
public function getDroitMenuParametre(): ?bool
{
return $this->droitMenuParametre;
}
public function setDroitMenuParametre(bool $droit): self
{
$this->droitMenuParametre = $droit;
return $this;
}
public function getDroitMenuListe(): ?bool
{
return $this->droitMenuListe;
}
public function setDroitMenuListe(bool $droit): self
{
$this->droitMenuListe = $droit;
return $this;
}
public function getDroitMenuConventionCollective(): ?bool
{
return $this->droitMenuConventionCollective;
}
public function setDroitMenuConventionCollective(bool $droit): self
{
$this->droitMenuConventionCollective = $droit;
return $this;
}
public function getDroitMenuExport(): ?bool
{
return $this->droitMenuExport;
}
public function setDroitMenuExport(bool $droit): self
{
$this->droitMenuExport = $droit;
return $this;
}
public function getDroitMenuCalcul(): ?bool
{
return $this->droitMenuCalcul;
}
public function setDroitMenuCalcul(bool $droit): self
{
$this->droitMenuCalcul = $droit;
return $this;
}
public function getDroitMenuRegle(): ?bool
{
return $this->droitMenuRegle;
}
public function setDroitMenuRegle(bool $droit): self
{
$this->droitMenuRegle = $droit;
return $this;
}
public function getDroitModificationRegleAvance(): ?bool
{
return $this->droitModificationRegleAvance;
}
public function setDroitModificationRegleAvance(bool $droit): self
{
$this->droitModificationRegleAvance = $droit;
return $this;
}
/**
* A visual identifier that represents this user.
*
* @see UserInterface
*/
public function getUsername(): string
{
return (string) $this->login;
}
/**
* @see UserInterface
*/
public function getRoles(): array
{
$roles =[];// $this->roles;
// guarantee every user at least has ROLE_USER
$roles[] = 'ROLE_USER';
if ($this->getEtat())
$roles[] = 'ROLE_ADMIN';
return array_unique($roles);
}
/**
* @see UserInterface
*/
public function getPassword(): string
{
return (string) $this->motdepasse;
}
/**
* @see UserInterface
*/
public function getSalt()
{
// not needed when using the "bcrypt" algorithm in security.yaml
}
/**
* @see UserInterface
*/
public function eraseCredentials()
{
// If you store any temporary, sensitive data on the user, clear it here
// $this->plainPassword = null;
}
/**
* @return Collection|Token[]
*/
public function getTokens(): Collection
{
return $this->tokens;
}
public function addTokens(Token $token): self
{
if (!$this->tokens->contains($token)) {
$this->tokens[] = $token;
}
return $this;
}
public function removeTokens(Token $token): self
{
if ($this->tokens->contains($token)) {
$this->tokens->removeElement($token);
}
return $this;
}
public function serialize()
{
return serialize(array(
$this->getId(),
$this->getLogin(),
$this->getPassword()
));
}
public function unserialize($serialized)
{
list(
$this->id,
$this->login,
$this->motdepasse
// voir remarques sur salt plus haut
// $this->salt
) = unserialize($serialized);
}
}