src/Entity/User.php line 21

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