src/Entity/User.php line 27

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Dae;
  4. use App\Entity\Autres;
  5. use App\Entity\Adresse;
  6. use App\Entity\Commande;
  7. use App\Entity\Entreprise;
  8. use App\Entity\Partenaire;
  9. use App\Entity\Particulier;
  10. use App\Entity\AgentInterne;
  11. use Doctrine\ORM\Mapping as ORM;
  12. use App\Repository\UserRepository;
  13. use Doctrine\Common\Collections\Collection;
  14. use Doctrine\Common\Collections\ArrayCollection;
  15. use Symfony\Component\Validator\Constraints as Assert;
  16. use Symfony\Component\Security\Core\User\UserInterface;
  17. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  18. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  19. #[ORM\Entity(repositoryClassUserRepository::class)]
  20. #[ORM\InheritanceType(value'JOINED')]
  21. #[ORM\DiscriminatorColumn(name'type'type'string')]
  22. #[ORM\DiscriminatorMap(value: ['User' => User::class,'Particulier' => Particulier::class, 'Partenaire' => Partenaire::class, 'Entreprise' => Entreprise::class, 'Dae' => Dae::class, 'ChargeAssistance' => ChargeAssistance::class, 'AgentInterne' => AgentInterne::class,'Autres' => Autres::class])]
  23. #[UniqueEntity(fields: ['email'], message'There is already an account with this email'entityClassUser::class)]
  24. class User implements UserInterfacePasswordAuthenticatedUserInterface
  25. {
  26.     public const PARTIICULIER 'Particulier';
  27.     public const ENTREPRISE 'Entreprise';
  28.     public const AUTRES 'Autres';
  29.     #[ORM\Id]
  30.     #[ORM\GeneratedValue]
  31.     #[ORM\Column(type'integer')]
  32.     private $id;
  33.     #[ORM\Column(type'string'length255uniquetrue)]
  34.     #[Assert\Email]
  35.     private $email;
  36.     #[ORM\Column(type'string'length255nullabletrue)]
  37.     private $username;
  38.     #[ORM\Column(type'string'length255nullabletrue)]
  39.     private $password;
  40.     #[ORM\Column(type'json'length255)]
  41.     private $roles = [];
  42.     #[ORM\Column(type'boolean')]
  43.     private $isVerified false;
  44.     #[ORM\ManyToMany(targetEntityGroupePermission::class, inversedBy'users')]
  45.     private $group_permission;
  46.     #[ORM\OneToMany(mappedBy'user'targetEntityAdresse::class, cascade: ['persist''remove'])]
  47.     private $adresses;
  48.     #[ORM\OneToMany(mappedBy'user'targetEntityCommande::class, cascade: ['persist''remove'])]
  49.     private $commande;
  50.     #[ORM\Column(type'string'length1000nullabletrue)]
  51.     private $TokenReset;
  52.     #[ORM\Column(type'boolean')]
  53.     private $isDeleted false;
  54.     #[ORM\OneToMany(mappedBy'user'targetEntityQuizReponse::class)]
  55.     private Collection $quizReponses;
  56.     #[ORM\OneToMany(mappedBy'user'targetEntityRessources::class, cascade: ['persist''remove'])]
  57.     private Collection $ressources;
  58.     #[ORM\OneToMany(mappedBy'user'targetEntityDocDemandeService::class, cascade: ['persist''remove'])]
  59.     private Collection $docDemande;
  60.     #[ORM\OneToMany(mappedBy'user'targetEntityInscriptionSessionFormation::class, cascade: ['persist''remove'])]
  61.     private Collection $inscriptionSessionFormations;
  62.     #[ORM\OneToMany(mappedBy'user'targetEntityForumReponse::class, cascade: ['persist''remove'])]
  63.     private ?Collection $forumResponses;
  64.     #[ORM\OneToMany(mappedBy'user'targetEntitySujetforum::class, cascade: ['persist''remove'])]
  65.     private ?Collection $sujetForums;
  66.     #[ORM\OneToMany(mappedBy'user'targetEntityUserFicheSatisfaction::class, orphanRemovaltrue)]
  67.     private Collection $userFicheSatisfactions;
  68.     #[ORM\OneToMany(mappedBy'user'targetEntityNotification::class)]
  69.     private Collection $notifications;
  70.     #[ORM\OneToMany(mappedBy'user'targetEntityDemandeService::class)]
  71.     private Collection $demandeServices;
  72.     public function __construct()
  73.     {
  74.         $this->group_permission = new ArrayCollection();
  75.         $this->adresses = new ArrayCollection();
  76.         $this->quizReponses = new ArrayCollection();
  77.         $this->ressources = new ArrayCollection();
  78.         $this->forumResponses = new ArrayCollection();
  79.         $this->sujetForums = new ArrayCollection();
  80.         $this->inscriptionSessionFormations = new ArrayCollection();
  81.         $this->commande = new ArrayCollection();
  82.         $this->docDemande = new ArrayCollection();
  83.         $this->userFicheSatisfactions = new ArrayCollection();
  84.         $this->notifications = new ArrayCollection();
  85.         $this->demandeServices = new ArrayCollection();
  86.     }
  87.     public function getId(): ?int
  88.     {
  89.         return $this->id;
  90.     }
  91.     public function getEmail(): ?string
  92.     {
  93.         return $this->email;
  94.     }
  95.     public function setEmail(string $email): self
  96.     {
  97.         $this->email $email;
  98.         return $this;
  99.     }
  100.     public function getUsername(): ?string
  101.     {
  102.         return $this->username;
  103.     }
  104.     public function setUsername(string $username): self
  105.     {
  106.         $this->username $username;
  107.         return $this;
  108.     }
  109.     public function getPassword(): ?string
  110.     {
  111.         return $this->password;
  112.     }
  113.     public function setPassword(?string $password): self
  114.     {
  115.         $this->password $password;
  116.         return $this;
  117.     }
  118.      /**
  119.      * The public representation of the user (e.g. a username, an email address, etc.)
  120.      *
  121.      * @see UserInterface
  122.      */
  123.     public function getUserIdentifier(): string
  124.     {
  125.         return (string) $this->email;
  126.     }
  127.         public function getRoles(): array
  128.         {
  129.             $roles = [];
  130.             // guarantee every user at least has ROLE_USER$roles[] = 'ROLE_USER';
  131.             if ($this->isVerified() == 1) {
  132.                 $roles $this->roles;
  133.                 return array_unique($roles);
  134.             }
  135.             //dd($roles);
  136.             return $roles;
  137.         }
  138.     public function setRoles(array $roles): self
  139.     {
  140.         $this->roles $roles;
  141.         return $this;
  142.     }
  143.     /**
  144.      * Returning a salt is only needed, if you are not using a modern
  145.      * hashing algorithm (e.g. bcrypt or sodium) in your security.yaml.
  146.      *
  147.      * @see UserInterface
  148.      */
  149.     public function getSalt(): ?string
  150.     {
  151.         return null;
  152.     }
  153.     /**
  154.      * @see UserInterface
  155.      */
  156.     public function eraseCredentials()
  157.     {
  158.         // If you store any temporary, sensitive data on the user, clear it here
  159.         // $this->plainPassword = null;
  160.     }
  161.     public function isVerified(): bool
  162.     {
  163.         return $this->isVerified;
  164.     }
  165.     public function setIsVerified(bool $isVerified): self
  166.     {
  167.         $this->isVerified $isVerified;
  168.         return $this;
  169.     }
  170.     public function getTokenReset(): ?string
  171.     {
  172.         return $this->TokenReset;
  173.     }
  174.     public function setTokenReset(?string $TokenReset): self
  175.     {
  176.         $this->TokenReset $TokenReset;
  177.         return $this;
  178.     }
  179.     public function isDeleted(): bool
  180.     {
  181.         return $this->isDeleted;
  182.     }
  183.     public function setIsDeleted(bool $isDeleted): void
  184.     {
  185.         $this->isDeleted $isDeleted;
  186.     }
  187.     /**
  188.      * @return Collection<int, GroupePermission>
  189.      */
  190.     public function getGroupPermission(): Collection
  191.     {
  192.         return $this->group_permission;
  193.     }
  194.     public function addGroupPermission(GroupePermission $groupPermission): self
  195.     {
  196.         if (!$this->group_permission->contains($groupPermission)) {
  197.             $this->group_permission[] = $groupPermission;
  198.         }
  199.         return $this;
  200.     }
  201.     public function removeGroupPermission(GroupePermission $groupPermission): self
  202.     {
  203.         $this->group_permission->removeElement($groupPermission);
  204.         return $this;
  205.     }
  206.     /**
  207.      * @return Collection<int, Adresse>
  208.      */
  209.     public function getAdresses(): Collection
  210.     {
  211.         return $this->adresses;
  212.     }
  213.     public function addAdress(Adresse $adress): self
  214.     {
  215.         if (!$this->adresses->contains($adress)) {
  216.             $this->adresses[] = $adress;
  217.             $adress->setUser($this);
  218.         }
  219.         return $this;
  220.     }
  221.     public function removeAdress(Adresse $adress): self
  222.     {
  223.         if ($this->adresses->removeElement($adress)) {
  224.             // set the owning side to null (unless already changed)
  225.             if ($adress->getUser() === $this) {
  226.                 $adress->setUser(null);
  227.             }
  228.         }
  229.         return $this;
  230.     }
  231.     public function isIsVerified(): ?bool
  232.     {
  233.         return $this->isVerified;
  234.     }
  235.     public function __toString()
  236.     {
  237.         return $this->username ?? $this->email ?? '';
  238.     }
  239.     /**
  240.      * @return Collection<int, QuizReponse>
  241.      */
  242.     public function getQuizReponses(): Collection
  243.     {
  244.         return $this->quizReponses;
  245.     }
  246.     public function addQuizReponse(QuizReponse $quizReponse): self
  247.     {
  248.         if (!$this->quizReponses->contains($quizReponse)) {
  249.             $this->quizReponses->add($quizReponse);
  250.             $quizReponse->setUser($this);
  251.         }
  252.         return $this;
  253.     }
  254.     public function removeQuizReponse(QuizReponse $quizReponse): self
  255.     {
  256.         if ($this->quizReponses->removeElement($quizReponse)) {
  257.             // set the owning side to null (unless already changed)
  258.             if ($quizReponse->getUser() === $this) {
  259.                 $quizReponse->setUser(null);
  260.             }
  261.         }
  262.         return $this;
  263.     }
  264.     /**
  265.      * @return Collection<int, Ressources>
  266.      */
  267.     public function getRessources(): Collection
  268.     {
  269.         return $this->ressources;
  270.     }
  271.     public function addRessource(Ressources $ressource): self
  272.     {
  273.         if (!$this->ressources->contains($ressource)) {
  274.             $this->ressources->add($ressource);
  275.             $ressource->setUser($this);
  276.         }
  277.         return $this;
  278.     }
  279.     public function removeRessource(Ressources $ressource): self
  280.     {
  281.         if ($this->ressources->removeElement($ressource)) {
  282.             // set the owning side to null (unless already changed)
  283.             if ($ressource->getUser() === $this) {
  284.                 $ressource->setUser(null);
  285.             }
  286.         }
  287.         return $this;
  288.     }
  289.     /**
  290.      * @return Collection<int, InscriptionSessionFormation>
  291.      */
  292.     public function getInscriptionSessionFormations(): Collection
  293.     {
  294.         return $this->inscriptionSessionFormations;
  295.     }
  296.     public function addInscriptionSessionFormation(InscriptionSessionFormation $inscriptionSessionFormation): self
  297.     {
  298.         if (!$this->inscriptionSessionFormations->contains($inscriptionSessionFormation)) {
  299.             $this->inscriptionSessionFormations->add($inscriptionSessionFormation);
  300.             $inscriptionSessionFormation->setUser($this);
  301.         }
  302.         return $this;
  303.     }
  304.     public function removeInscriptionSessionFormation(InscriptionSessionFormation $inscriptionSessionFormation): self
  305.     {
  306.         if ($this->inscriptionSessionFormations->removeElement($inscriptionSessionFormation)) {
  307.             // set the owning side to null (unless already changed)
  308.             if ($inscriptionSessionFormation->getUser() === $this) {
  309.                 $inscriptionSessionFormation->setUser(null);
  310.             }
  311.         }
  312.         return $this;
  313.     }
  314.     /**
  315.      * @return Collection<int, forumResponse>
  316.      */
  317.     public function getForumResponses(): Collection
  318.     {
  319.         return $this->forumResponses;
  320.     }
  321.     public function addForumResponses(ForumReponse $forumResponses): self
  322.     {
  323.         if (!$this->forumResponses->contains($forumResponses)) {
  324.             $this->forumResponses[] = $forumResponses;
  325.             $forumResponses->setUser($this);
  326.         }
  327.         return $this;
  328.     }
  329.     public function removeForumResponses(ForumReponse $forumResponses): self
  330.     {
  331.         if ($this->forumResponses->removeElement($forumResponses)) {
  332.             // set the owning side to null (unless already changed)
  333.             if ($forumResponses->getUser() === $this) {
  334.                 $forumResponses->setUser(null);
  335.             }
  336.         }
  337.         return $this;
  338.     }
  339.     /**
  340.      * @return Collection<int, sujetForum>
  341.      */
  342.     public function getSujetResponses(): Collection
  343.     {
  344.         return $this->sujetForums;
  345.     }
  346.     public function addSujetResponses(Sujetforum $sujetForum): self
  347.     {
  348.         if (!$this->sujetForums->contains($sujetForum)) {
  349.             $this->sujetForums[] = $sujetForum;
  350.             $sujetForum->setUser($this);
  351.         }
  352.         return $this;
  353.     }
  354.     public function removeSujetForums(Sujetforum $sujetForum): self
  355.     {
  356.         if ($this->sujetForums->removeElement($sujetForum)) {
  357.             // set the owning side to null (unless already changed)
  358.             if ($sujetForum->getUser() === $this) {
  359.                 $sujetForum->setUser(null);
  360.             }
  361.         }
  362.         return $this;
  363.     }
  364.     /**
  365.      * @return Collection<int, Commande>
  366.      */
  367.     public function getCommande(): Collection
  368.     {
  369.         return $this->commande;
  370.     }
  371.     public function addCommande(Commande $commande): self
  372.     {
  373.         if (!$this->commande->contains($commande)) {
  374.             $this->commande->add($commande);
  375.             $commande->setUser($this);
  376.         }
  377.         return $this;
  378.     }
  379.     public function removeCommande(Commande $commande): self
  380.     {
  381.         if ($this->commande->removeElement($commande)) {
  382.             // set the owning side to null (unless already changed)
  383.             if ($commande->getUser() === $this) {
  384.                 $commande->setUser(null);
  385.             }
  386.         }
  387.         return $this;
  388.     }
  389.     public function addForumResponse(ForumReponse $forumResponse): self
  390.     {
  391.         if (!$this->forumResponses->contains($forumResponse)) {
  392.             $this->forumResponses->add($forumResponse);
  393.             $forumResponse->setUser($this);
  394.         }
  395.         return $this;
  396.     }
  397.     public function removeForumResponse(ForumReponse $forumResponse): self
  398.     {
  399.         if ($this->forumResponses->removeElement($forumResponse)) {
  400.             // set the owning side to null (unless already changed)
  401.             if ($forumResponse->getUser() === $this) {
  402.                 $forumResponse->setUser(null);
  403.             }
  404.         }
  405.         return $this;
  406.     }
  407.     /**
  408.      * @return Collection<int, Sujetforum>
  409.      */
  410.     public function getSujetForums(): Collection
  411.     {
  412.         return $this->sujetForums;
  413.     }
  414.     public function addSujetForum(Sujetforum $sujetForum): self
  415.     {
  416.         if (!$this->sujetForums->contains($sujetForum)) {
  417.             $this->sujetForums->add($sujetForum);
  418.             $sujetForum->setUser($this);
  419.         }
  420.         return $this;
  421.     }
  422.     public function removeSujetForum(Sujetforum $sujetForum): self
  423.     {
  424.         if ($this->sujetForums->removeElement($sujetForum)) {
  425.             // set the owning side to null (unless already changed)
  426.             if ($sujetForum->getUser() === $this) {
  427.                 $sujetForum->setUser(null);
  428.             }
  429.         }
  430.         return $this;
  431.     }
  432.     /**
  433.      * @return Collection<int, DocDemandeService>
  434.      */
  435.     public function getDocDemande(): Collection
  436.     {
  437.         return $this->docDemande;
  438.     }
  439.     public function addDocDemande(DocDemandeService $docDemande): self
  440.     {
  441.         if (!$this->docDemande->contains($docDemande)) {
  442.             $this->docDemande->add($docDemande);
  443.             $docDemande->setUser($this);
  444.         }
  445.         return $this;
  446.     }
  447.     public function removeDocDemande(DocDemandeService $docDemande): self
  448.     {
  449.         if ($this->docDemande->removeElement($docDemande)) {
  450.             // set the owning side to null (unless already changed)
  451.             if ($docDemande->getUser() === $this) {
  452.                 $docDemande->setUser(null);
  453.             }
  454.         }
  455.         return $this;
  456.     }
  457.     /**
  458.      * @return Collection<int, UserFicheSatisfaction>
  459.      */
  460.     public function getUserFicheSatisfactions(): Collection
  461.     {
  462.         return $this->userFicheSatisfactions;
  463.     }
  464.     public function addUserFicheSatisfaction(UserFicheSatisfaction $userFicheSatisfaction): self
  465.     {
  466.         if (!$this->userFicheSatisfactions->contains($userFicheSatisfaction)) {
  467.             $this->userFicheSatisfactions->add($userFicheSatisfaction);
  468.             $userFicheSatisfaction->setUser($this);
  469.         }
  470.         return $this;
  471.     }
  472.     public function removeUserFicheSatisfaction(UserFicheSatisfaction $userFicheSatisfaction): self
  473.     {
  474.         if ($this->userFicheSatisfactions->removeElement($userFicheSatisfaction)) {
  475.             // set the owning side to null (unless already changed)
  476.             if ($userFicheSatisfaction->getUser() === $this) {
  477.                 $userFicheSatisfaction->setUser(null);
  478.             }
  479.         }
  480.         return $this;
  481.     }
  482.     public function isIsDeleted(): ?bool
  483.     {
  484.         return $this->isDeleted;
  485.     }
  486.     /**
  487.      * @return Collection<int, Notification>
  488.      */
  489.     public function getNotifications(): Collection
  490.     {
  491.         return $this->notifications;
  492.     }
  493.     public function addNotification(Notification $notification): self
  494.     {
  495.         if (!$this->notifications->contains($notification)) {
  496.             $this->notifications->add($notification);
  497.             $notification->setUser($this);
  498.         }
  499.         return $this;
  500.     }
  501.     public function removeNotification(Notification $notification): self
  502.     {
  503.         if ($this->notifications->removeElement($notification)) {
  504.             // set the owning side to null (unless already changed)
  505.             if ($notification->getUser() === $this) {
  506.                 $notification->setUser(null);
  507.             }
  508.         }
  509.         return $this;
  510.     }
  511.     /**
  512.      * @return Collection<int, DemandeService>
  513.      */
  514.     public function getDemandeServices(): Collection
  515.     {
  516.         return $this->demandeServices;
  517.     }
  518.     public function addDemandeService(DemandeService $demandeService): self
  519.     {
  520.         if (!$this->demandeServices->contains($demandeService)) {
  521.             $this->demandeServices->add($demandeService);
  522.             $demandeService->setUser($this);
  523.         }
  524.         return $this;
  525.     }
  526.     public function removeDemandeService(DemandeService $demandeService): self
  527.     {
  528.         if ($this->demandeServices->removeElement($demandeService)) {
  529.             // set the owning side to null (unless already changed)
  530.             if ($demandeService->getUser() === $this) {
  531.                 $demandeService->setUser(null);
  532.             }
  533.         }
  534.         return $this;
  535.     }
  536. }