src/Entity/User.php line 23

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use DateTimeImmutable;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use App\Repository\UserRepository;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\Common\Collections\ArrayCollection;
  8. use Symfony\Component\Uid\Uuid;
  9. use Symfony\Component\Validator\Constraints as Assert;
  10. use Symfony\Component\Security\Core\User\UserInterface;
  11. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  12. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  13. use App\Entity\Instance;
  14. use Symfony\Component\Validator\Context\ExecutionContextInterface;
  15. use League\OAuth2\Server\Entities\UserEntityInterface;
  16. /**
  17.  * @ORM\Entity(repositoryClass=UserRepository::class)
  18.  * @UniqueEntity(fields={"email"}, message="Cette adresse email est déjà utilisé")
  19.  * @ORM\HasLifecycleCallbacks
  20.  */
  21. class User implements UserInterfacePasswordAuthenticatedUserInterfaceUserEntityInterface
  22. {
  23.     public const ROLE_SUPER_ADMIN 'ROLE_SUPER_ADMIN';
  24.     public const ROLE_ADMIN 'ROLE_ADMIN';
  25.     public const ROLE_DIRECTEUR 'ROLE_DIRECTEUR';
  26.     public const ROLE_CHEF_REDACTEUR 'ROLE_CHEF_REDACTEUR';
  27.     public const ROLE_ADJOINT_REDACTEUR 'ROLE_ADJOINT_REDACTEUR';
  28.     public const ROLE_CHEF_RUBRIQUE 'ROLE_CHEF_RUBRIQUE';
  29.     public const ROLE_REDACTEUR 'ROLE_REDACTEUR';
  30.     public const ROLE_USER 'ROLE_USER';
  31.     /**
  32.      * @ORM\Id
  33.      * @ORM\GeneratedValue
  34.      * @ORM\Column(type="integer")
  35.      */
  36.     private $id;
  37.     /**
  38.      * @ORM\Column(type="string", length=180, unique=true)
  39.      * @Assert\NotBlank()
  40.      * @Assert\Email()
  41.      */
  42.     private $email;
  43.     /**
  44.      * @ORM\Column(type="json")
  45.      */
  46.     private $roles = [];
  47.     /**
  48.      * @var string The hashed password
  49.      * @ORM\Column(type="string")
  50.      * @Assert\NotBlank(message="Veuillez entrer un mot de passe")
  51.      * @Assert\Length(min="8", minMessage="Le mot de passe doit faire au moins 8 caratères")
  52.      */
  53.     private $password;
  54.     /**
  55.      * @Assert\EqualTo(propertyPath="password", message="Les mots de passes ne correspondent pas")
  56.      */
  57.     private $passwordConfirm;
  58.     /**
  59.      * @ORM\OneToMany(targetEntity=BlogPostLike::class, mappedBy="user")
  60.      */
  61.     private $blogPostLikes;
  62.     /**
  63.      * @ORM\Column(type="datetime", nullable=true)
  64.      */
  65.     private $createdAt;
  66.     /**
  67.      * @ORM\Column(type="datetime", nullable=true)
  68.      */
  69.     private ?\DateTimeInterface $updatedAt null;
  70.     /**
  71.      * @ORM\Column(type="boolean", options={"default": false}, nullable=true)
  72.      */
  73.     private $isItmConnect;
  74.     /**
  75.      * @ORM\Column(type="text", nullable=true)
  76.      */
  77.     private $refreshToken;
  78.     /**
  79.      * @ORM\ManyToMany(targetEntity="BlogPostCategory", inversedBy="users")
  80.      * @ORM\JoinColumn(nullable=true,onDelete="SET NULL")
  81.      * )
  82.      */
  83.     private $blogPostCategories;
  84.     /**
  85.      * @ORM\OneToMany(targetEntity=UserNotificationEntry::class, mappedBy="user", orphanRemoval=true)
  86.      */
  87.     private $userNotificationEntries;
  88.     /**
  89.      * @ORM\ManyToMany(targetEntity=Preference::class)
  90.      */
  91.     private $preference;
  92.     /**
  93.      * @ORM\OneToMany(targetEntity=Contributor::class, mappedBy="user")
  94.      */
  95.     private $contributors;
  96.     /**
  97.      * @ORM\Column(type="string", length=255, nullable=true)
  98.      */
  99.     private $tokenFirebase;
  100.     /**
  101.      * @ORM\Column(type="boolean", nullable=true)
  102.      */
  103.     private $acceptCgu;
  104.     /**
  105.      * @ORM\Column(type="uuid", unique=true, nullable=true)
  106.      */
  107.     private ?Uuid $uuid null;
  108.     /**
  109.      * @ORM\OneToMany(mappedBy="user", targetEntity=OAuth2UserConsent::class, orphanRemoval=true)
  110.      */
  111.     private Collection $oAuth2UserConsents;
  112.     /**
  113.      * @ORM\OneToMany(targetEntity=BlogPost::class, mappedBy="author")
  114.      */
  115.     private $blogPosts;
  116.     /**
  117.      * @ORM\ManyToMany(targetEntity=Criteria1Item::class)
  118.      */
  119.     private $criteria1Items;
  120.     /**
  121.      * @ORM\ManyToMany(targetEntity=Criteria2Item::class)
  122.      */
  123.     private $criteria2Items;
  124.     /**
  125.      * @ORM\ManyToMany(targetEntity=Criteria3Item::class)
  126.      */
  127.     private $criteria3Items;
  128.     /**
  129.      * @ORM\ManyToMany(targetEntity=Criteria4Item::class)
  130.      */
  131.     private $criteria4Items;
  132.     /**
  133.      * @ORM\ManyToMany(targetEntity=Criteria5Item::class)
  134.      */
  135.     private $criteria5Items;
  136.     /**
  137.      * @ORM\Column(type="datetime", nullable=true)
  138.      */
  139.     private $firebaseTokenGeneratedAt;
  140.     /**
  141.      * @ORM\OneToMany(targetEntity=Scoring::class, mappedBy="user", orphanRemoval=true)
  142.      */
  143.     private $scorings;
  144.     /**
  145.      * @ORM\ManyToMany(targetEntity=Instance::class, inversedBy="users")
  146.      */
  147.     private Collection $instances;
  148.     /**
  149.      * @ORM\Column(type="boolean", options={"default": false})
  150.      */
  151.     private bool $allowSelfEdit false;
  152.     /**
  153.      * @ORM\Column(type="boolean", options={"default": false})
  154.      */
  155.     private bool $anonymizationEnabled false;
  156.     /**
  157.      * Indique si l'utilisateur a confirmé la popup d'anonymisation
  158.      * @ORM\Column(type="boolean", options={"default": false})
  159.      */
  160.     private bool $isAnonymisationConfirmed false;
  161.     /**
  162.      * Retourne vrai si l'utilisateur a confirmé la popup d'anonymisation
  163.      */
  164.     public function isAnonymisationConfirmed(): bool
  165.     {
  166.         return $this->isAnonymisationConfirmed;
  167.     }
  168.     /**
  169.      * Définit la confirmation d'anonymisation
  170.      */
  171.     public function setAnonymisationConfirmed(bool $confirmed): self
  172.     {
  173.         $this->isAnonymisationConfirmed $confirmed;
  174.         return $this;
  175.     }
  176.     /**
  177.      * @ORM\Column(type="string", length=512, nullable=true)
  178.      */
  179.     private ?string $firstName null;
  180.     /**
  181.      * @ORM\Column(type="string", length=512, nullable=true)
  182.      */
  183.     private ?string $lastName null;
  184.     /**
  185.      * @ORM\Column(type="string", length=512, nullable=true)
  186.      */
  187.     private ?string $entityCode null;
  188.     /**
  189.      * @ORM\Column(type="string", length=512, nullable=true)
  190.      * @Assert\Email(message="Veuillez saisir un email professionnel valide")
  191.      */
  192.     private ?string $proEmail null;
  193.     /**
  194.      * @ORM\Column(type="string", length=512, nullable=true)
  195.      * @Assert\Regex(
  196.      *     pattern="/^\d*$/",
  197.      *     message="Le téléphone professionnel doit contenir uniquement des chiffres."
  198.      * )
  199.      */
  200.     private ?string $proPhone null;
  201.     /**
  202.      * @ORM\Column(type="string", length=255, nullable=true)
  203.      */
  204.     private ?string $photoPath null;
  205.     /**
  206.      * @ORM\Column(type="boolean", options={"default": 0})
  207.      */
  208.     private bool $acceptPrivacy false;
  209.     /**
  210.      * @ORM\Column(type="datetime_immutable", nullable=true)
  211.      */
  212.     private ?DateTimeImmutable $acceptPrivacyAt null;
  213.     /**
  214.      * @ORM\Column(type="string", length=32, nullable=true)
  215.      */
  216.     private ?string $acceptPrivacyVersion null;
  217.     /**
  218.      * @ORM\Column(type="boolean", options={"default": 0})
  219.      */
  220.     private bool $privacyChecked false;
  221.     public function __construct()
  222.     {
  223.         $this->blogPostLikes = new ArrayCollection();
  224.         $this->createdAt = new \DateTime();
  225.         $this->blogPostCategories = new ArrayCollection();
  226.         $this->userNotificationEntries = new ArrayCollection();
  227.         $this->preference = new ArrayCollection();
  228.         $this->contributors = new ArrayCollection();
  229.         $this->oAuth2UserConsents = new ArrayCollection();
  230.         $this->blogPosts = new ArrayCollection();
  231.         $this->criteria1Items = new ArrayCollection();
  232.         $this->criteria2Items = new ArrayCollection();
  233.         $this->criteria3Items = new ArrayCollection();
  234.         $this->criteria4Items = new ArrayCollection();
  235.         $this->criteria5Items = new ArrayCollection();
  236.         $this->scorings = new ArrayCollection();
  237.         $this->instances = new ArrayCollection();
  238.         // Init updatedAt with the same value as createdAt at creation time
  239.         $this->updatedAt $this->createdAt;
  240.     }
  241.     /**
  242.      * @return int|null
  243.      */
  244.     public function getId(): ?int
  245.     {
  246.         return $this->id;
  247.     }
  248.     /**
  249.      * @return string|null
  250.      */
  251.     public function getEmail(): ?string
  252.     {
  253.         return $this->email;
  254.     }
  255.     /**
  256.      * @param string $email
  257.      * @return $this
  258.      */
  259.     public function setEmail(string $email): self
  260.     {
  261.         $this->email $email;
  262.         return $this;
  263.     }
  264.     public function getCreatedAt(): ?\DateTimeInterface
  265.     {
  266.         return $this->createdAt;
  267.     }
  268.     public function setCreatedAt(?\DateTimeInterface $createdAt): self
  269.     {
  270.         $this->createdAt $createdAt;
  271.         // Keep updatedAt in sync initially if it's not set yet
  272.         if ($this->updatedAt === null) {
  273.             $this->updatedAt $createdAt;
  274.         }
  275.         return $this;
  276.     }
  277.     public function getUpdatedAt(): ?\DateTimeInterface
  278.     {
  279.         return $this->updatedAt;
  280.     }
  281.     public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
  282.     {
  283.         $this->updatedAt $updatedAt;
  284.         return $this;
  285.     }
  286.     /**
  287.      * Met à jour automatiquement la date de modification avant insert
  288.      * @ORM\PrePersist
  289.      */
  290.     public function onPrePersist(): void
  291.     {
  292.         $now = new \DateTime();
  293.         if ($this->createdAt === null) {
  294.             $this->createdAt $now;
  295.         }
  296.         $this->updatedAt $this->createdAt ?? $now;
  297.     }
  298.     /**
  299.      * Met à jour automatiquement la date de modification avant update
  300.      * @ORM\PreUpdate
  301.      */
  302.     public function onPreUpdate(): void
  303.     {
  304.         $this->updatedAt = new \DateTime();
  305.     }
  306.     /**
  307.      * A visual identifier that represents this user.
  308.      *
  309.      * @see UserInterface
  310.      */
  311.     public function getUserIdentifier(): string
  312.     {
  313.         return (string) $this->email;
  314.     }
  315.     /**
  316.      * Required by UserEntityInterface for OAuth2 server
  317.      *
  318.      * @see UserEntityInterface
  319.      */
  320.     public function getIdentifier(): ?string
  321.     {
  322.         return (string) $this->id;
  323.     }
  324.     /**
  325.      * @deprecated since Symfony 5.3, use getUserIdentifier instead
  326.      */
  327.     public function getUsername(): string
  328.     {
  329.         return (string) $this->email;
  330.     }
  331.     public function __toString(): string
  332.     {
  333.         return (string) $this->email;
  334.     }
  335.     /**
  336.      * @see UserInterface
  337.      */
  338.     public function getRoles(): array
  339.     {
  340.         $roles $this->roles;
  341.         // guarantee every user at least has ROLE_USER
  342.         $roles[] = User::ROLE_USER;
  343.         return array_unique($roles);
  344.     }
  345.     public function getRolesList(): string
  346.     {
  347.         return implode(", "$this->roles);
  348.     }
  349.     public function getRolesString(): string
  350.     {
  351.         $roleString "[";
  352.         foreach ($this->roles as $key => $role) {
  353.             $roleString .= '"' $role '"';
  354.             if ($key count($this->roles) - 1)
  355.                 $roleString .= ',';
  356.         }
  357.         $roleString .= "]";
  358.         return $roleString;
  359.     }
  360.     public function hasRole(string $role): bool
  361.     {
  362.         return in_array($role$this->getRoles());
  363.     }
  364.     /**
  365.      * @param array $roles
  366.      * @return $this
  367.      */
  368.     public function setRoles(array $roles): self
  369.     {
  370.         $this->roles $roles;
  371.         return $this;
  372.     }
  373.     public function getPasswordConfirm(): ?string
  374.     {
  375.         return $this->passwordConfirm;
  376.     }
  377.     public function setPasswordConfirm(string $passwordConfirm): self
  378.     {
  379.         $this->passwordConfirm $passwordConfirm;
  380.         return $this;
  381.     }
  382.     /**
  383.      * @see PasswordAuthenticatedUserInterface
  384.      */
  385.     public function getPassword(): ?string
  386.     {
  387.         return $this->password;
  388.     }
  389.     public function setPassword(string $password): self
  390.     {
  391.         $this->password $password;
  392.         return $this;
  393.     }
  394.     /**
  395.      * Returning a salt is only needed, if you are not using a modern
  396.      * hashing algorithm (e.g. bcrypt or sodium) in your security.yaml.
  397.      *
  398.      * @see UserInterface
  399.      */
  400.     public function getSalt(): ?string
  401.     {
  402.         return null;
  403.     }
  404.     /**
  405.      * @see UserInterface
  406.      */
  407.     public function eraseCredentials()
  408.     {
  409.         // If you store any temporary, sensitive data on the user, clear it here
  410.         // $this->plainPassword = null;
  411.     }
  412.     /**
  413.      * @return Collection|BlogPostLike[]
  414.      */
  415.     public function getBlogPostLikes(): Collection
  416.     {
  417.         return $this->blogPostLikes;
  418.     }
  419.     public function addBlogPostLike(BlogPostLike $blogPostLike): self
  420.     {
  421.         if (!$this->blogPostLikes->contains($blogPostLike)) {
  422.             $this->blogPostLikes[] = $blogPostLike;
  423.             $blogPostLike->setUser($this);
  424.         }
  425.         return $this;
  426.     }
  427.     public function removeBlogPostLike(BlogPostLike $blogPostLike): self
  428.     {
  429.         if ($this->blogPostLikes->removeElement($blogPostLike)) {
  430.             // set the owning side to null (unless already changed)
  431.             if ($blogPostLike->getUser() === $this) {
  432.                 $blogPostLike->setUser(null);
  433.             }
  434.         }
  435.         return $this;
  436.     }
  437.     /**
  438.      * @return Collection|BlogPostCategory[]
  439.      */
  440.     public function getBlogPostCategories(): Collection
  441.     {
  442.         return $this->blogPostCategories;
  443.     }
  444.     public function addBlogPostCategory(BlogPostCategory $blogPostCategory): self
  445.     {
  446.         if (!$this->blogPostCategories->contains($blogPostCategory)) {
  447.             $this->blogPostCategories[] = $blogPostCategory;
  448.             $blogPostCategory->addUser($this);
  449.         }
  450.         return $this;
  451.     }
  452.     public function removeBlogPostCategory(BlogPostCategory $rubrique): self
  453.     {
  454.         $this->blogPostCategories->removeElement($rubrique);
  455.         return $this;
  456.     }
  457.     /**
  458.      * @return Collection<int, UserNotificationEntry>
  459.      */
  460.     public function getUserNotificationEntries(): Collection
  461.     {
  462.         return $this->userNotificationEntries;
  463.     }
  464.     public function addUserNotificationEntry(UserNotificationEntry $userNotificationEntry): self
  465.     {
  466.         if (!$this->userNotificationEntries->contains($userNotificationEntry)) {
  467.             $this->userNotificationEntries[] = $userNotificationEntry;
  468.             $userNotificationEntry->setUser($this);
  469.         }
  470.         return $this;
  471.     }
  472.     public function removeUserNotificationEntry(UserNotificationEntry $userNotificationEntry): self
  473.     {
  474.         if ($this->userNotificationEntries->removeElement($userNotificationEntry)) {
  475.             // set the owning side to null (unless already changed)
  476.             if ($userNotificationEntry->getUser() === $this) {
  477.                 $userNotificationEntry->setUser(null);
  478.             }
  479.         }
  480.         return $this;
  481.     }
  482.     public function isItmConnect(): ?bool
  483.     {
  484.         return $this->isItmConnect;
  485.     }
  486.     public function getIsItmConnect(): bool
  487.     {
  488.         return $this->isItmConnect;
  489.     }
  490.     public function setIsItmConnect(bool $ItmConnect): self
  491.     {
  492.         $this->isItmConnect $ItmConnect;
  493.         return $this;
  494.     }
  495.     /**
  496.      * @return Collection<int, Preference>
  497.      */
  498.     public function getPreference(): Collection
  499.     {
  500.         return $this->preference;
  501.     }
  502.     public function getPreferenceString(): string
  503.     {
  504.         $preferences $this->preference;
  505.         $preferenceString "";
  506.         if (count($preferences) > 0) {
  507.             for ($i 0$i count($preferences); $i++) {
  508.                 if ($i == count($preferences) - 1) {
  509.                     $preferenceString $preferenceString "" $preferences[$i]->getId();
  510.                 } else {
  511.                     $preferenceString $preferenceString "" $preferences[$i]->getId() . ",";
  512.                 }
  513.             }
  514.         }
  515.         return $preferenceString;
  516.     }
  517.     public function addPreference(Preference $preference): self
  518.     {
  519.         if (!$this->preference->contains($preference)) {
  520.             $this->preference[] = $preference;
  521.         }
  522.         return $this;
  523.     }
  524.     public function removePreference(Preference $preference): self
  525.     {
  526.         $this->preference->removeElement($preference);
  527.         return $this;
  528.     }
  529.     public function getRefreshToken(): ?string
  530.     {
  531.         return $this->refreshToken;
  532.     }
  533.     public function setRefreshToken(string $refreshToken): self
  534.     {
  535.         $this->refreshToken $refreshToken;
  536.         return $this;
  537.     }
  538.     /**
  539.      * @return Collection<int, Contributor>
  540.      */
  541.     public function getContributors(): Collection
  542.     {
  543.         return $this->contributors;
  544.     }
  545.     public function addContributor(Contributor $contributor): self
  546.     {
  547.         if (!$this->contributors->contains($contributor)) {
  548.             $this->contributors[] = $contributor;
  549.             $contributor->setUser($this);
  550.         }
  551.         return $this;
  552.     }
  553.     public function removeContributor(Contributor $contributor): self
  554.     {
  555.         if ($this->contributors->removeElement($contributor)) {
  556.             // set the owning side to null (unless already changed)
  557.             if ($contributor->getUser() === $this) {
  558.                 $contributor->setUser(null);
  559.             }
  560.         }
  561.         return $this;
  562.     }
  563.     public function getTokenFirebase(): ?string
  564.     {
  565.         return $this->tokenFirebase;
  566.     }
  567.     public function setTokenFirebase(?string $tokenFirebase): self
  568.     {
  569.         $this->tokenFirebase $tokenFirebase;
  570.         return $this;
  571.     }
  572.     public function isAcceptCgu(): ?bool
  573.     {
  574.         return $this->acceptCgu;
  575.     }
  576.     public function setAcceptCgu(?bool $acceptCgu): self
  577.     {
  578.         $this->acceptCgu $acceptCgu;
  579.         return $this;
  580.     }
  581.     public function getUuid(): ?Uuid
  582.     {
  583.         return $this->uuid;
  584.     }
  585.     public function setUuid(Uuid $uuid): self
  586.     {
  587.         $this->uuid $uuid;
  588.         return $this;
  589.     }
  590.     /**
  591.      * @return Collection<int, OAuth2UserConsent>
  592.      */
  593.     public function getOAuth2UserConsents(): Collection
  594.     {
  595.         return $this->oAuth2UserConsents;
  596.     }
  597.     public function addOAuth2UserConsent(OAuth2UserConsent $oAuth2UserConsent): self
  598.     {
  599.         if (!$this->oAuth2UserConsents->contains($oAuth2UserConsent)) {
  600.             $this->oAuth2UserConsents->add($oAuth2UserConsent);
  601.             $oAuth2UserConsent->setUser($this);
  602.         }
  603.         return $this;
  604.     }
  605.     public function removeOAuth2UserConsent(OAuth2UserConsent $oAuth2UserConsent): self
  606.     {
  607.         if ($this->oAuth2UserConsents->removeElement($oAuth2UserConsent)) {
  608.             // set the owning side to null (unless already changed)
  609.             if ($oAuth2UserConsent->getUser() === $this) {
  610.                 $oAuth2UserConsent->setUser(null);
  611.             }
  612.         }
  613.         return $this;
  614.     }
  615.     public function canAccessBO(): bool
  616.     {
  617.         return
  618.             $this->hasRole(User::ROLE_SUPER_ADMIN) ||
  619.             $this->hasRole(User::ROLE_ADMIN) ||
  620.             $this->hasRole(User::ROLE_DIRECTEUR) ||
  621.             $this->hasRole(User::ROLE_CHEF_REDACTEUR) ||
  622.             $this->hasRole(User::ROLE_ADJOINT_REDACTEUR) ||
  623.             $this->hasRole(User::ROLE_CHEF_RUBRIQUE) ||
  624.             $this->hasRole(User::ROLE_REDACTEUR);
  625.     }
  626.     /**
  627.      * @return Collection<int, BlogPost>
  628.      */
  629.     public function getBlogPosts(): Collection
  630.     {
  631.         return $this->blogPosts;
  632.     }
  633.     public function addBlogPost(BlogPost $blogPost): self
  634.     {
  635.         if (!$this->blogPosts->contains($blogPost)) {
  636.             $this->blogPosts[] = $blogPost;
  637.             $blogPost->setAuthor($this);
  638.         }
  639.         return $this;
  640.     }
  641.     public function removeBlogPost(BlogPost $blogPost): self
  642.     {
  643.         if ($this->blogPosts->removeElement($blogPost)) {
  644.             // set the owning side to null (unless already changed)
  645.             if ($blogPost->getAuthor() === $this) {
  646.                 $blogPost->setAuthor(null);
  647.             }
  648.         }
  649.         return $this;
  650.     }
  651.     /**
  652.      * @return Collection<int, Criteria1Item>
  653.      */
  654.     public function getCriteria1Items(): Collection
  655.     {
  656.         return $this->criteria1Items;
  657.     }
  658.     public function getCriteria1ItemsList(): string
  659.     {
  660.         return implode(", "$this->criteria1Items->toArray());
  661.     }
  662.     public function getCriteria1ItemsString(): string
  663.     {
  664.         $string "[";
  665.         foreach ($this->criteria1Items as $key => $criteria) {
  666.             $string .= '"' $criteria '"';
  667.             if ($key count($this->criteria1Items) - 1)
  668.                 $string .= ',';
  669.         }
  670.         $string .= "]";
  671.         return $string;
  672.     }
  673.     public function addCriteria1Item(Criteria1Item $criteria1Item): self
  674.     {
  675.         if (!$this->criteria1Items->contains($criteria1Item)) {
  676.             $this->criteria1Items[] = $criteria1Item;
  677.         }
  678.         return $this;
  679.     }
  680.     /**
  681.      * @return Collection<int, Criteria2Item>
  682.      */
  683.     public function getCriteria2Items(): Collection
  684.     {
  685.         return $this->criteria2Items;
  686.     }
  687.     public function getCriteria2ItemsList(): string
  688.     {
  689.         return implode(", "$this->criteria2Items->toArray());
  690.     }
  691.     public function getCriteria2ItemsString(): string
  692.     {
  693.         $string "[";
  694.         foreach ($this->criteria2Items as $key => $criteria) {
  695.             $string .= '"' $criteria '"';
  696.             if ($key count($this->criteria2Items) - 1)
  697.                 $string .= ',';
  698.         }
  699.         $string .= "]";
  700.         return $string;
  701.     }
  702.     public function addCriteria2Item(Criteria2Item $criteria2Item): self
  703.     {
  704.         if (!$this->criteria2Items->contains($criteria2Item)) {
  705.             $this->criteria2Items[] = $criteria2Item;
  706.         }
  707.         return $this;
  708.     }
  709.     /**
  710.      * @return Collection<int, Criteria3Item>
  711.      */
  712.     public function getCriteria3Items(): Collection
  713.     {
  714.         return $this->criteria3Items;
  715.     }
  716.     public function getCriteria3ItemsList(): string
  717.     {
  718.         return implode(", "$this->criteria3Items->toArray());
  719.     }
  720.     public function getCriteria3ItemsString(): string
  721.     {
  722.         $string "[";
  723.         foreach ($this->criteria3Items as $key => $criteria) {
  724.             $string .= '"' $criteria '"';
  725.             if ($key count($this->criteria3Items) - 1)
  726.                 $string .= ',';
  727.         }
  728.         $string .= "]";
  729.         return $string;
  730.     }
  731.     public function addCriteria3Item(Criteria3Item $criteria3Item): self
  732.     {
  733.         if (!$this->criteria3Items->contains($criteria3Item)) {
  734.             $this->criteria3Items[] = $criteria3Item;
  735.         }
  736.         return $this;
  737.     }
  738.     /**
  739.      * @return Collection<int, Criteria4Item>
  740.      */
  741.     public function getCriteria4Items(): Collection
  742.     {
  743.         return $this->criteria4Items;
  744.     }
  745.     public function getCriteria4ItemsList(): string
  746.     {
  747.         return implode(", "$this->criteria4Items->toArray());
  748.     }
  749.     public function getCriteria4ItemsString(): string
  750.     {
  751.         $string "[";
  752.         foreach ($this->criteria4Items as $key => $criteria) {
  753.             $string .= '"' $criteria '"';
  754.             if ($key count($this->criteria4Items) - 1)
  755.                 $string .= ',';
  756.         }
  757.         $string .= "]";
  758.         return $string;
  759.     }
  760.     public function addCriteria4Item(Criteria4Item $criteria4Item): self
  761.     {
  762.         if (!$this->criteria4Items->contains($criteria4Item)) {
  763.             $this->criteria4Items[] = $criteria4Item;
  764.         }
  765.         return $this;
  766.     }
  767.     /**
  768.      * @return Collection<int, Criteria5Item>
  769.      */
  770.     public function getCriteria5Items(): Collection
  771.     {
  772.         return $this->criteria5Items;
  773.     }
  774.     public function getCriteria5ItemsList(): string
  775.     {
  776.         return implode(", "$this->criteria5Items->toArray());
  777.     }
  778.     public function getCriteria5ItemsString(): string
  779.     {
  780.         $string "[";
  781.         foreach ($this->criteria5Items as $key => $criteria) {
  782.             $string .= '"' $criteria '"';
  783.             if ($key count($this->criteria5Items) - 1)
  784.                 $string .= ',';
  785.         }
  786.         $string .= "]";
  787.         return $string;
  788.     }
  789.     // AVANT (bug) : public function addCriteria5Item(Criteria4Item $criteria5Item): self
  790.     public function addCriteria5Item(Criteria5Item $criteria5Item): self
  791.     {
  792.         if (!$this->criteria5Items->contains($criteria5Item)) {
  793.             $this->criteria5Items[] = $criteria5Item;
  794.         }
  795.         return $this;
  796.     }
  797.     public function getTokenFirebaseGeneratedAt(): ?\DateTimeInterface
  798.     {
  799.         return $this->firebaseTokenGeneratedAt;
  800.     }
  801.     public function setTokenFirebaseGeneratedAt(?\DateTimeInterface $firebaseTokenGeneratedAt): self
  802.     {
  803.         $this->firebaseTokenGeneratedAt $firebaseTokenGeneratedAt;
  804.         return $this;
  805.     }
  806.     /**
  807.      * @return Collection<int, Scoring>
  808.      */
  809.     public function getScorings(): Collection
  810.     {
  811.         return $this->scorings;
  812.     }
  813.     public function addScoring(Scoring $scoring): self
  814.     {
  815.         if (!$this->scorings->contains($scoring)) {
  816.             $this->scorings[] = $scoring;
  817.             $scoring->setUser($this);
  818.         }
  819.         return $this;
  820.     }
  821.     public function removeScoring(Scoring $scoring): self
  822.     {
  823.         if ($this->scorings->removeElement($scoring)) {
  824.             if ($scoring->getUser() === $this) {
  825.                 $scoring->setUser(null);
  826.             }
  827.         }
  828.         return $this;
  829.     }
  830.     /**
  831.      * @return Collection<int, Instance>
  832.      */
  833.     public function getInstances(): Collection
  834.     {
  835.         return $this->instances;
  836.     }
  837.     public function getInstancesList(): string
  838.     {
  839.         return implode(", "$this->instances->toArray());
  840.     }
  841.     public function getInstancesString(): string
  842.     {
  843.         $string "[";
  844.         foreach ($this->instances as $key => $instance) {
  845.             $string .= '"' $instance->getName() . '"';
  846.             if ($key count($this->instances) - 1) {
  847.                 $string .= ',';
  848.             }
  849.         }
  850.         $string .= "]";
  851.         return $string;
  852.     }
  853.     public function addInstance(Instance $instance): self
  854.     {
  855.         if (!$this->instances->contains($instance)) {
  856.             $this->instances[] = $instance;
  857.         }
  858.         return $this;
  859.     }
  860.     public function removeInstance(Instance $instance): self
  861.     {
  862.         $this->instances->removeElement($instance);
  863.         return $this;
  864.     }
  865.     public function hasInstance(Instance $instance): bool
  866.     {
  867.         return $this->instances->contains($instance);
  868.     }
  869.     /**
  870.      * @return bool
  871.      */
  872.     public function isAllowSelfEdit(): bool
  873.     {
  874.         return (bool) $this->allowSelfEdit;
  875.     }
  876.     /**
  877.      * @param bool $allowSelfEdit 
  878.      * @return self
  879.      */
  880.     public function setAllowSelfEdit(bool $allowSelfEdit): self
  881.     {
  882.         $this->allowSelfEdit $allowSelfEdit;
  883.         return $this;
  884.     }
  885.     /**
  886.      * @return bool
  887.      */
  888.     public function isAnonymizationEnabled(): bool
  889.     {
  890.         return $this->anonymizationEnabled;
  891.     }
  892.     /**
  893.      * @param bool $anonymizationEnabled 
  894.      * @return self
  895.      */
  896.     public function setAnonymizationEnabled(bool $anonymizationEnabled): self
  897.     {
  898.         $this->anonymizationEnabled $anonymizationEnabled;
  899.         return $this;
  900.     }
  901.     /**
  902.      * @return 
  903.      */
  904.     public function getFirstName(): ?string
  905.     {
  906.         return $this->firstName;
  907.     }
  908.     /**
  909.      * @param  $firstName 
  910.      * @return self
  911.      */
  912.     public function setFirstName(?string $firstName): self
  913.     {
  914.         $this->firstName $firstName;
  915.         return $this;
  916.     }
  917.     /**
  918.      * @return 
  919.      */
  920.     public function getLastName(): ?string
  921.     {
  922.         return $this->lastName;
  923.     }
  924.     /**
  925.      * @param  $lastName 
  926.      * @return self
  927.      */
  928.     public function setLastName(?string $lastName): self
  929.     {
  930.         $this->lastName $lastName;
  931.         return $this;
  932.     }
  933.     /**
  934.      * @return 
  935.      */
  936.     public function getEntityCode(): ?string
  937.     {
  938.         return $this->entityCode;
  939.     }
  940.     /**
  941.      * @param  $entityCode 
  942.      * @return self
  943.      */
  944.     public function setEntityCode(?string $entityCode): self
  945.     {
  946.         $this->entityCode $entityCode;
  947.         return $this;
  948.     }
  949.     /**
  950.      * @return 
  951.      */
  952.     public function getPhotoPath(): ?string
  953.     {
  954.         return $this->photoPath;
  955.     }
  956.     /**
  957.      * @param  $photoPath 
  958.      * @return self
  959.      */
  960.     public function setPhotoPath(?string $photoPath): self
  961.     {
  962.         $this->photoPath $photoPath;
  963.         return $this;
  964.     }
  965.     /**
  966.      * @return 
  967.      */
  968.     public function getProEmail(): ?string
  969.     {
  970.         return $this->proEmail;
  971.     }
  972.     /**
  973.      * @param  $proEmail 
  974.      * @return self
  975.      */
  976.     public function setProEmail(?string $proEmail): self
  977.     {
  978.         $this->proEmail $proEmail;
  979.         return $this;
  980.     }
  981.     /**
  982.      * @return 
  983.      */
  984.     public function getProPhone(): ?string
  985.     {
  986.         return $this->proPhone;
  987.     }
  988.     /**
  989.      * @param  $proPhone 
  990.      * @return self
  991.      */
  992.     public function setProPhone(?string $proPhone): self
  993.     {
  994.         $this->proPhone $proPhone;
  995.         return $this;
  996.     }
  997.     public function isAcceptPrivacy(): bool
  998.     {
  999.         return $this->acceptPrivacy;
  1000.     }
  1001.     public function setAcceptPrivacy(bool $acceptPrivacy): self
  1002.     {
  1003.         $this->acceptPrivacy $acceptPrivacy;
  1004.         return $this;
  1005.     }
  1006.     public function getAcceptPrivacyAt(): ?DateTimeImmutable
  1007.     {
  1008.         return $this->acceptPrivacyAt;
  1009.     }
  1010.     public function setAcceptPrivacyAt(?DateTimeImmutable $acceptPrivacyAt): self
  1011.     {
  1012.         $this->acceptPrivacyAt $acceptPrivacyAt;
  1013.         return $this;
  1014.     }
  1015.     public function getAcceptPrivacyVersion(): ?string
  1016.     {
  1017.         return $this->acceptPrivacyVersion;
  1018.     }
  1019.     public function setAcceptPrivacyVersion(?string $acceptPrivacyVersion): self
  1020.     {
  1021.         $this->acceptPrivacyVersion $acceptPrivacyVersion;
  1022.         return $this;
  1023.     }
  1024.     public function isPrivacyChecked(): bool
  1025.     {
  1026.         return $this->privacyChecked;
  1027.     }
  1028.     public function setPrivacyChecked(bool $value): self
  1029.     {
  1030.         $this->privacyChecked $value;
  1031.         return $this;
  1032.     }
  1033.     #[Assert\Callback(groups: ['identity'])]
  1034.     public function validateIdentity(ExecutionContextInterface $context): void
  1035.     {
  1036.         // Si l’admin coche "Autoriser l’utilisateur à compléter/modifier ses infos"
  1037.         // => on n'impose pas les champs d’identité côté back-office.
  1038.         if ($this->isAllowSelfEdit() || $this->isAnonymizationEnabled()) {
  1039.             return;
  1040.         }
  1041.         // Sinon : ces champs deviennent obligatoires côté admin
  1042.         $lastName trim((string) $this->getLastName());
  1043.         $firstName trim((string) $this->getFirstName());
  1044.         $entity trim((string) $this->getEntityCode());
  1045.         if ($lastName === '') {
  1046.             $context->buildViolation('Le nom est obligatoire.')
  1047.                 ->atPath('lastName')
  1048.                 ->addViolation();
  1049.         }
  1050.         if ($firstName === '') {
  1051.             $context->buildViolation('Le prénom est obligatoire.')
  1052.                 ->atPath('firstName')
  1053.                 ->addViolation();
  1054.         }
  1055.         if ($entity === '') {
  1056.             $context->buildViolation('L’entité / code entité est obligatoire.')
  1057.                 ->atPath('entityCode')
  1058.                 ->addViolation();
  1059.         }
  1060.     }
  1061.     // Criteria 1
  1062.     public function removeCriteria1Item(Criteria1Item $criteria1Item): self
  1063.     {
  1064.         $this->criteria1Items->removeElement($criteria1Item);
  1065.         return $this;
  1066.     }
  1067.     // Criteria 2
  1068.     public function removeCriteria2Item(Criteria2Item $criteria2Item): self
  1069.     {
  1070.         $this->criteria2Items->removeElement($criteria2Item);
  1071.         return $this;
  1072.     }
  1073.     // Criteria 3
  1074.     public function removeCriteria3Item(Criteria3Item $criteria3Item): self
  1075.     {
  1076.         $this->criteria3Items->removeElement($criteria3Item);
  1077.         return $this;
  1078.     }
  1079.     // Criteria 4
  1080.     public function removeCriteria4Item(Criteria4Item $criteria4Item): self
  1081.     {
  1082.         $this->criteria4Items->removeElement($criteria4Item);
  1083.         return $this;
  1084.     }
  1085.     // Criteria 5
  1086.     public function removeCriteria5Item(Criteria5Item $criteria5Item): self
  1087.     {
  1088.         $this->criteria5Items->removeElement($criteria5Item);
  1089.         return $this;
  1090.     }
  1091. }