<?php
namespace App\Entity;
use App\Repository\UserRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Serializer\Annotation\MaxDepth;
use Symfony\Component\Serializer\Annotation\Ignore;
use App\Traits\Timestampable;
use App\Traits\Blameable;
/**
* @ORM\Table(name="user")
* @ORM\Entity(repositoryClass=UserRepository::class)
*/
class User implements UserInterface, PasswordAuthenticatedUserInterface
{
use Timestampable;
use Blameable;
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="integer")
*/
private $statut;
/**
* @ORM\Column(type="string", length=180, unique=true)
*/
private $email;
/**
* @ORM\Column(type="string", length=255)
*/
private $prenom;
/**
* @ORM\Column(type="string", length=255)
*/
private $nom;
/**
* @ORM\Column(type="string", length=255)
*/
private $trigramme;
/**
* @Ignore()
* @ORM\Column(type="text")
* @MaxDepth(1)
*/
private $roles;
/**
* @var string The hashed password
* @Ignore()
* @ORM\Column(type="string")
* @MaxDepth(1)
*/
private $password;
/**
* @Ignore()
* @ORM\Column(type="string", unique=true, nullable=true)
* @MaxDepth(1)
*/
private $apiToken;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $externe;
// /**
// * @Ignore()
// * @ORM\OneToMany(targetEntity=FormSectionDroit::class, mappedBy="user")
// * @MaxDepth(1)
// */
// private $sectionDroits;
/**
* @Ignore()
* @ORM\OneToMany(targetEntity=FormSectionVisa::class, mappedBy="user")
*/
private $sectionVisas;
/**
* @Ignore()
* @ORM\OneToMany(targetEntity=Favori::class, mappedBy="user")
* @ORM\OrderBy({"position" = "ASC"})
*/
private $favoris;
/**
* @ORM\OneToMany(targetEntity=Onglet::class, mappedBy="user", orphanRemoval=true)
* @Ignore()
*/
private $onglets;
/**
* @Ignore()
* @ORM\OneToMany(targetEntity=MenuInvisible::class, mappedBy="user", orphanRemoval=true)
*/
private $menuInvisibles;
/**
* @ORM\Column(type="integer", nullable=true)
* @Ignore()
*/
private $tabsAtLogin;
/**
* @ORM\OneToMany(targetEntity=OngletLogin::class, mappedBy="user")
* @Ignore()
*/
private $ongletsAtLogin;
/**
* @ORM\Column(type="string", length=555, nullable=true)
* @Ignore()
*/
private $avatar;
/**
* @Ignore()
* @ORM\OneToMany(targetEntity="App\Entity\Log", mappedBy="user_crea")
* @MaxDepth(1)
*/
private $logs;
/**
* @Ignore()
* @ORM\OneToMany(targetEntity=WebsocketMessage::class, mappedBy="user", orphanRemoval=true)
* @MaxDepth(1)
*/
private $websocketMessages;
/**
* @ORM\Column(type="string", length=255, options={"default" : "fr"})
*/
private $langage = 'fr';
/**
* @ORM\OneToMany(targetEntity=UtilisateurMine::class, mappedBy="user", orphanRemoval=true)
*/
private $utilisateurMines;
/**
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="responsableListUsers")
*/
private $responsable;
/**
* @ORM\OneToMany(targetEntity=User::class, mappedBy="responsable")
*/
private $responsableListUsers;
/**
* @ORM\Column(type="string", length=5000, nullable=true)
*/
private $notes;
/**
* @ORM\OneToMany(targetEntity=DroitInvisible::class, mappedBy="user")
*/
private $droitInvisibles;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Ignore()
* @MaxDepth(1)
*/
private $tokenRefresh;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $dateRefresh;
public function __construct()
{
$this->sectionVisas = new ArrayCollection();
$this->favoris = new ArrayCollection();
$this->onglets = new ArrayCollection();
$this->menuInvisibles = new ArrayCollection();
$this->ongletsAtLogin = new ArrayCollection();
$this->logs = new ArrayCollection();
$this->websocketMessages = new ArrayCollection();
$this->utilisateurMines = new ArrayCollection();
$this->responsableListUsers = new ArrayCollection();
$this->droitInvisibles = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getStatut(): ?int
{
return $this->statut;
}
public function setStatut(string $statut): self
{
$this->statut = $statut;
return $this;
}
public function getUsername(): ?string
{
return $this->email;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(string $email): self
{
$this->email = $email;
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 getTrigramme(): ?string
{
return $this->trigramme;
}
public function setTrigramme(string $trigramme): self
{
$this->trigramme = $trigramme;
return $this;
}
public function getApiToken(): ?string
{
return $this->apiToken;
}
public function setApiToken(string $apiToken): self
{
$this->apiToken = $apiToken;
return $this;
}
/**
* A visual identifier that represents this user.
*
* @see UserInterface
*/
public function getUserIdentifier(): string
{
return (string) $this->email;
}
/**
* @see UserInterface
*/
public function getRoles(): array
{
$tabRoles = json_decode($this->roles, true);
$roles = !is_null($tabRoles) ? $tabRoles : [];
// guarantee every user at least has ROLE_USER
$roles[] = 'ROLE_USER';
return array_unique($roles);
}
public function setRoles(array $roles): self
{
$this->roles = json_encode($roles);
return $this;
}
/**
* @see PasswordAuthenticatedUserInterface
*/
public function getPassword(): string
{
return $this->password;
}
public function setPassword(string $password): self
{
$this->password = $password;
return $this;
}
public function setExterne(bool $externe): self
{
$this->externe = $externe;
return $this;
}
public function getExterne()
{
return $this->externe;
}
/**
* Returning a salt is only needed, if you are not using a modern
* hashing algorithm (e.g. bcrypt or sodium) in your security.yaml.
*
* @see UserInterface
*/
public function getSalt(): ?string
{
return null;
}
/**
* @see UserInterface
*/
public function eraseCredentials()
{
// If you store any temporary, sensitive data on the user, clear it here
// $this->plainPassword = null;
}
/**
* @return Collection|FormSectionVisa[]
*/
public function getSectionVisas(): Collection
{
return $this->sectionVisas;
}
public function addSectionVisa(FormSectionVisa $sectionVisa): self
{
if (!$this->sectionVisas->contains($sectionVisa)) {
$this->sectionVisas[] = $sectionVisa;
$sectionVisa->setUser($this);
}
return $this;
}
public function removeSectionVisa(FormSectionVisa $sectionVisa): self
{
if ($this->sectionVisas->removeElement($sectionVisa)) {
// set the owning side to null (unless already changed)
if ($sectionVisa->getUser() === $this) {
$sectionVisa->setUser(null);
}
}
return $this;
}
/**
* @return Collection|Favori[]
*/
public function getFavoris(): Collection
{
return $this->favoris;
}
public function addFavori(Favori $favori): self
{
if (!$this->favoris->contains($favori)) {
$this->favoris[] = $favori;
$favori->setUser($this);
}
return $this;
}
public function removeFavori(Favori $favori): self
{
if ($this->favoris->removeElement($favori)) {
// set the owning side to null (unless already changed)
if ($favori->getUser() === $this) {
$favori->setUser(null);
}
}
return $this;
}
/**
* @return Collection|Onglet[]
*/
public function getOnglets(): Collection
{
return $this->onglets;
}
public function addOnglet(Onglet $onglet): self
{
if (!$this->onglets->contains($onglet)) {
$this->onglets[] = $onglet;
$onglet->setUser($this);
}
return $this;
}
public function removeOnglet(Onglet $onglet): self
{
if ($this->onglets->removeElement($onglet)) {
// set the owning side to null (unless already changed)
if ($onglet->getUser() === $this) {
$onglet->setUser(null);
}
}
return $this;
}
/**
* @return Collection|MenuInvisible[]
*/
public function getMenuInvisibles(): Collection
{
return $this->menuInvisibles;
}
public function addMenuInvisible(MenuInvisible $menuInvisible): self
{
if (!$this->menuInvisibles->contains($menuInvisible)) {
$this->menuInvisibles[] = $menuInvisible;
$menuInvisible->setUser($this);
}
return $this;
}
public function removeMenuInvisible(MenuInvisible $menuInvisible): self
{
if ($this->menuInvisibles->removeElement($menuInvisible)) {
// set the owning side to null (unless already changed)
if ($menuInvisible->getUser() === $this) {
$menuInvisible->setUser(null);
}
}
return $this;
}
public function getTabsAtLogin(): ?int
{
return $this->tabsAtLogin;
}
public function setTabsAtLogin(?int $tabsAtLogin): self
{
$this->tabsAtLogin = $tabsAtLogin;
return $this;
}
/**
* @return Collection|OngletLogin[]
*/
public function getOngletsAtLogin(): Collection
{
return $this->ongletsAtLogin;
}
public function addOngletsAtLogin(OngletLogin $ongletsAtLogin): self
{
if (!$this->ongletsAtLogin->contains($ongletsAtLogin)) {
$this->ongletsAtLogin[] = $ongletsAtLogin;
$ongletsAtLogin->setUser($this);
}
return $this;
}
public function removeOngletsAtLogin(OngletLogin $ongletsAtLogin): self
{
if ($this->ongletsAtLogin->removeElement($ongletsAtLogin)) {
// set the owning side to null (unless already changed)
if ($ongletsAtLogin->getUser() === $this) {
$ongletsAtLogin->setUser(null);
}
}
return $this;
}
/**
* @return string
*/
public function getAvatar(): ?string
{
return $this->avatar;
}
/**
* @param string $avatar Chemin de l'avatar
* @return User
*/
public function setAvatar(?string $avatar): self
{
$this->avatar = $avatar;
return $this;
}
/**
* @return Collection|Log[]
*/
public function getLogs(): Collection
{
return $this->logs;
}
public function addLog(Log $log): self
{
if (!$this->logs->contains($log)) {
$this->logs[] = $log;
$log->setUserCrea($this);
}
return $this;
}
public function removeLog(Log $log): self
{
if ($this->logs->contains($log)) {
$this->logs->removeElement($log);
// set the owning side to null (unless already changed)
if ($log->getUserCrea() === $this) {
$log->setUserCrea(null);
}
}
return $this;
}
/**
* @return Collection|WebsocketMessage[]
*/
public function getWebsocketMessages(): Collection
{
return $this->websocketMessages;
}
public function addWebsocketMessage(WebsocketMessage $websocketMessage): self
{
if (!$this->websocketMessages->contains($websocketMessage)) {
$this->websocketMessages[] = $websocketMessage;
$websocketMessage->setUser($this);
}
return $this;
}
public function removeWebsocketMessage(WebsocketMessage $websocketMessage): self
{
if ($this->websocketMessages->removeElement($websocketMessage)) {
// set the owning side to null (unless already changed)
if ($websocketMessage->getUser() === $this) {
$websocketMessage->setUser(null);
}
}
return $this;
}
public function getLangage(): ?string
{
return $this->langage;
}
public function setLangage(string $langage): self
{
$this->langage = $langage;
return $this;
}
/**
* @return Collection|UtilisateurMine[]
*/
public function getUtilisateurMines(): Collection
{
return $this->utilisateurMines;
}
public function setUtilisateurMines($utilisateurMines)
{
$this->utilisateurMines = $utilisateurMines;
return $this;
}
public function addUtilisateurMine(UtilisateurMine $utilisateurMine): self
{
if (!$this->utilisateurMines->contains($utilisateurMine)) {
$this->utilisateurMines[] = $utilisateurMine;
$utilisateurMine->setUser($this);
}
return $this;
}
public function removeUtilisateurMine(UtilisateurMine $utilisateurMine): self
{
if ($this->utilisateurMines->removeElement($utilisateurMine)) {
// set the owning side to null (unless already changed)
if ($utilisateurMine->getUser() === $this) {
$utilisateurMine->setUser(null);
}
}
return $this;
}
public function getResponsable(): ?self
{
return $this->responsable;
}
public function setResponsable(?self $responsable): self
{
$this->responsable = $responsable;
return $this;
}
/**
* @return Collection|self[]
*/
public function getResponsableListUsers(): Collection
{
return $this->responsableListUsers;
}
public function addResponsableListUser(self $responsableListUser): self
{
if (!$this->responsableListUsers->contains($responsableListUser)) {
$this->responsableListUsers[] = $responsableListUser;
$responsableListUser->setResponsable($this);
}
return $this;
}
public function removeResponsableListUser(self $responsableListUser): self
{
if ($this->responsableListUsers->removeElement($responsableListUser)) {
// set the owning side to null (unless already changed)
if ($responsableListUser->getResponsable() === $this) {
$responsableListUser->setResponsable(null);
}
}
return $this;
}
public function getNotes(): ?string
{
return $this->notes;
}
public function setNotes(?string $notes): self
{
$this->notes = $notes;
return $this;
}
/**
* @return Collection<int, DroitInvisible>
*/
public function getDroitInvisibles(): Collection
{
return $this->droitInvisibles;
}
public function addDroitInvisible(DroitInvisible $droitInvisible): self
{
if (!$this->droitInvisibles->contains($droitInvisible)) {
$this->droitInvisibles[] = $droitInvisible;
$droitInvisible->setUser($this);
}
return $this;
}
public function removeDroitInvisible(DroitInvisible $droitInvisible): self
{
if ($this->droitInvisibles->removeElement($droitInvisible)) {
// set the owning side to null (unless already changed)
if ($droitInvisible->getUser() === $this) {
$droitInvisible->setUser(null);
}
}
return $this;
}
/**
* Get token refresh
*
* @return string
*/
public function getTokenRefresh()
{
return $this->tokenRefresh;
}
/**
* Set token refresh
*
* @param string $tokenRefresh token refresh
*
* @return self
*/
public function setTokenRefresh(string $tokenRefresh)
{
$this->tokenRefresh = $tokenRefresh;
return $this;
}
/**
* Get the value of dateRefresh
*/
public function getDateRefresh()
{
return $this->dateRefresh;
}
/**
* Set the value of dateRefresh
*
* @return self
*/
public function setDateRefresh($dateRefresh)
{
$this->dateRefresh = $dateRefresh;
return $this;
}
}