<?php
namespace App\Entity;
use DateTimeImmutable;
use Doctrine\ORM\Mapping as ORM;
use App\Repository\UserRepository;
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\ArrayCollection;
use Symfony\Component\Uid\Uuid;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
use App\Entity\Instance;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
/**
* @ORM\Entity(repositoryClass=UserRepository::class)
* @UniqueEntity(fields={"email"}, message="Cette adresse email est déjà utilisé")
*/
class User implements UserInterface, PasswordAuthenticatedUserInterface
{
public const ROLE_SUPER_ADMIN = 'ROLE_SUPER_ADMIN';
public const ROLE_ADMIN = 'ROLE_ADMIN';
public const ROLE_DIRECTEUR = 'ROLE_DIRECTEUR';
public const ROLE_CHEF_REDACTEUR = 'ROLE_CHEF_REDACTEUR';
public const ROLE_ADJOINT_REDACTEUR = 'ROLE_ADJOINT_REDACTEUR';
public const ROLE_CHEF_RUBRIQUE = 'ROLE_CHEF_RUBRIQUE';
public const ROLE_REDACTEUR = 'ROLE_REDACTEUR';
public const ROLE_USER = 'ROLE_USER';
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=180, unique=true)
* @Assert\NotBlank()
* @Assert\Email()
*/
private $email;
/**
* @ORM\Column(type="json")
*/
private $roles = [];
/**
* @var string The hashed password
* @ORM\Column(type="string")
* @Assert\NotBlank(message="Veuillez entrer un mot de passe")
* @Assert\Length(min="8", minMessage="Le mot de passe doit faire au moins 8 caratères")
*/
private $password;
/**
* @Assert\EqualTo(propertyPath="password", message="Les mots de passes ne correspondent pas")
*/
private $passwordConfirm;
/**
* @ORM\OneToMany(targetEntity=BlogPostLike::class, mappedBy="user")
*/
private $blogPostLikes;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $createdAt;
/**
* @ORM\Column(type="boolean", options={"default": false}, nullable=true)
*/
private $isItmConnect;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $refreshToken;
/**
* @ORM\ManyToMany(targetEntity="BlogPostCategory", inversedBy="users")
* @ORM\JoinColumn(nullable=true,onDelete="SET NULL")
* )
*/
private $blogPostCategories;
/**
* @ORM\OneToMany(targetEntity=UserNotificationEntry::class, mappedBy="user", orphanRemoval=true)
*/
private $userNotificationEntries;
/**
* @ORM\ManyToMany(targetEntity=Preference::class)
*/
private $preference;
/**
* @ORM\OneToMany(targetEntity=Contributor::class, mappedBy="user")
*/
private $contributors;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $tokenFirebase;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $acceptCgu;
/**
* @ORM\Column(type="uuid", unique=true, nullable=true)
*/
private ?Uuid $uuid = null;
/**
* @ORM\OneToMany(mappedBy="user", targetEntity=OAuth2UserConsent::class, orphanRemoval=true)
*/
private Collection $oAuth2UserConsents;
/**
* @ORM\OneToMany(targetEntity=BlogPost::class, mappedBy="author")
*/
private $blogPosts;
/**
* @ORM\ManyToMany(targetEntity=Criteria1Item::class)
*/
private $criteria1Items;
/**
* @ORM\ManyToMany(targetEntity=Criteria2Item::class)
*/
private $criteria2Items;
/**
* @ORM\ManyToMany(targetEntity=Criteria3Item::class)
*/
private $criteria3Items;
/**
* @ORM\ManyToMany(targetEntity=Criteria4Item::class)
*/
private $criteria4Items;
/**
* @ORM\ManyToMany(targetEntity=Criteria5Item::class)
*/
private $criteria5Items;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $firebaseTokenGeneratedAt;
/**
* @ORM\OneToMany(targetEntity=Scoring::class, mappedBy="user", orphanRemoval=true)
*/
private $scorings;
/**
* @ORM\ManyToMany(targetEntity=Instance::class, inversedBy="users")
*/
private Collection $instances;
/**
* @ORM\Column(type="boolean", options={"default": false})
*/
private bool $allowSelfEdit = false;
/**
* @ORM\Column(type="boolean", options={"default": false})
*/
private bool $anonymizationEnabled = false;
/**
* @ORM\Column(type="string", length=512, nullable=true)
*/
private ?string $firstName = null;
/**
* @ORM\Column(type="string", length=512, nullable=true)
*/
private ?string $lastName = null;
/**
* @ORM\Column(type="string", length=512, nullable=true)
*/
private ?string $entityCode = null;
/**
* @ORM\Column(type="string", length=512, nullable=true)
* @Assert\Email(message="Veuillez saisir un email professionnel valide")
*/
private ?string $proEmail = null;
/**
* @ORM\Column(type="string", length=512, nullable=true)
* @Assert\Regex(
* pattern="/^\d*$/",
* message="Le téléphone professionnel doit contenir uniquement des chiffres."
* )
*/
private ?string $proPhone = null;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $photoPath = null;
/**
* @ORM\Column(type="boolean", options={"default": 0})
*/
private bool $acceptPrivacy = false;
/**
* @ORM\Column(type="datetime_immutable", nullable=true)
*/
private ?DateTimeImmutable $acceptPrivacyAt = null;
/**
* @ORM\Column(type="string", length=32, nullable=true)
*/
private ?string $acceptPrivacyVersion = null;
/**
* @ORM\Column(type="boolean", options={"default": 0})
*/
private bool $privacyChecked = false;
public function __construct()
{
$this->blogPostLikes = new ArrayCollection();
$this->createdAt = new \DateTime();
$this->blogPostCategories = new ArrayCollection();
$this->userNotificationEntries = new ArrayCollection();
$this->preference = new ArrayCollection();
$this->contributors = new ArrayCollection();
$this->oAuth2UserConsents = new ArrayCollection();
$this->blogPosts = new ArrayCollection();
$this->criteria1Items = new ArrayCollection();
$this->criteria2Items = new ArrayCollection();
$this->criteria3Items = new ArrayCollection();
$this->criteria4Items = new ArrayCollection();
$this->criteria5Items = new ArrayCollection();
$this->scorings = new ArrayCollection();
$this->instances = new ArrayCollection();
}
/**
* @return int|null
*/
public function getId(): ?int
{
return $this->id;
}
/**
* @return string|null
*/
public function getEmail(): ?string
{
return $this->email;
}
/**
* @param string $email
* @return $this
*/
public function setEmail(string $email): self
{
$this->email = $email;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(?\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
/**
* A visual identifier that represents this user.
*
* @see UserInterface
*/
public function getUserIdentifier(): string
{
return (string) $this->email;
}
/**
* @deprecated since Symfony 5.3, use getUserIdentifier instead
*/
public function getUsername(): string
{
return (string) $this->email;
}
public function __toString(): string
{
return (string) $this->email;
}
/**
* @see UserInterface
*/
public function getRoles(): array
{
$roles = $this->roles;
// guarantee every user at least has ROLE_USER
$roles[] = User::ROLE_USER;
return array_unique($roles);
}
public function getRolesList(): string
{
return implode(", ", $this->roles);
}
public function getRolesString(): string
{
$roleString = "[";
foreach ($this->roles as $key => $role) {
$roleString .= '"' . $role . '"';
if ($key < count($this->roles) - 1)
$roleString .= ',';
}
$roleString .= "]";
return $roleString;
}
public function hasRole(string $role): bool
{
return in_array($role, $this->getRoles());
}
/**
* @param array $roles
* @return $this
*/
public function setRoles(array $roles): self
{
$this->roles = $roles;
return $this;
}
public function getPasswordConfirm(): ?string
{
return $this->passwordConfirm;
}
public function setPasswordConfirm(string $passwordConfirm): self
{
$this->passwordConfirm = $passwordConfirm;
return $this;
}
/**
* @see PasswordAuthenticatedUserInterface
*/
public function getPassword(): ?string
{
return $this->password;
}
public function setPassword(string $password): self
{
$this->password = $password;
return $this;
}
/**
* Returning a salt is only needed, if you are not using a modern
* hashing algorithm (e.g. bcrypt or sodium) in your security.yaml.
*
* @see UserInterface
*/
public function getSalt(): ?string
{
return null;
}
/**
* @see UserInterface
*/
public function eraseCredentials()
{
// If you store any temporary, sensitive data on the user, clear it here
// $this->plainPassword = null;
}
/**
* @return Collection|BlogPostLike[]
*/
public function getBlogPostLikes(): Collection
{
return $this->blogPostLikes;
}
public function addBlogPostLike(BlogPostLike $blogPostLike): self
{
if (!$this->blogPostLikes->contains($blogPostLike)) {
$this->blogPostLikes[] = $blogPostLike;
$blogPostLike->setUser($this);
}
return $this;
}
public function removeBlogPostLike(BlogPostLike $blogPostLike): self
{
if ($this->blogPostLikes->removeElement($blogPostLike)) {
// set the owning side to null (unless already changed)
if ($blogPostLike->getUser() === $this) {
$blogPostLike->setUser(null);
}
}
return $this;
}
/**
* @return Collection|BlogPostCategory[]
*/
public function getBlogPostCategories(): Collection
{
return $this->blogPostCategories;
}
public function addBlogPostCategory(BlogPostCategory $blogPostCategory): self
{
if (!$this->blogPostCategories->contains($blogPostCategory)) {
$this->blogPostCategories[] = $blogPostCategory;
$blogPostCategory->addUser($this);
}
return $this;
}
public function removeBlogPostCategory(BlogPostCategory $rubrique): self
{
$this->blogPostCategories->removeElement($rubrique);
return $this;
}
/**
* @return Collection<int, UserNotificationEntry>
*/
public function getUserNotificationEntries(): Collection
{
return $this->userNotificationEntries;
}
public function addUserNotificationEntry(UserNotificationEntry $userNotificationEntry): self
{
if (!$this->userNotificationEntries->contains($userNotificationEntry)) {
$this->userNotificationEntries[] = $userNotificationEntry;
$userNotificationEntry->setUser($this);
}
return $this;
}
public function removeUserNotificationEntry(UserNotificationEntry $userNotificationEntry): self
{
if ($this->userNotificationEntries->removeElement($userNotificationEntry)) {
// set the owning side to null (unless already changed)
if ($userNotificationEntry->getUser() === $this) {
$userNotificationEntry->setUser(null);
}
}
return $this;
}
public function isItmConnect(): ?bool
{
return $this->isItmConnect;
}
public function getIsItmConnect(): bool
{
return $this->isItmConnect;
}
public function setIsItmConnect(bool $ItmConnect): self
{
$this->isItmConnect = $ItmConnect;
return $this;
}
/**
* @return Collection<int, Preference>
*/
public function getPreference(): Collection
{
return $this->preference;
}
public function getPreferenceString(): string
{
$preferences = $this->preference;
$preferenceString = "";
if (count($preferences) > 0) {
for ($i = 0; $i < count($preferences); $i++) {
if ($i == count($preferences) - 1) {
$preferenceString = $preferenceString . "" . $preferences[$i]->getId();
} else {
$preferenceString = $preferenceString . "" . $preferences[$i]->getId() . ",";
}
}
}
return $preferenceString;
}
public function addPreference(Preference $preference): self
{
if (!$this->preference->contains($preference)) {
$this->preference[] = $preference;
}
return $this;
}
public function removePreference(Preference $preference): self
{
$this->preference->removeElement($preference);
return $this;
}
public function getRefreshToken(): ?string
{
return $this->refreshToken;
}
public function setRefreshToken(string $refreshToken): self
{
$this->refreshToken = $refreshToken;
return $this;
}
/**
* @return Collection<int, Contributor>
*/
public function getContributors(): Collection
{
return $this->contributors;
}
public function addContributor(Contributor $contributor): self
{
if (!$this->contributors->contains($contributor)) {
$this->contributors[] = $contributor;
$contributor->setUser($this);
}
return $this;
}
public function removeContributor(Contributor $contributor): self
{
if ($this->contributors->removeElement($contributor)) {
// set the owning side to null (unless already changed)
if ($contributor->getUser() === $this) {
$contributor->setUser(null);
}
}
return $this;
}
public function getTokenFirebase(): ?string
{
return $this->tokenFirebase;
}
public function setTokenFirebase(?string $tokenFirebase): self
{
$this->tokenFirebase = $tokenFirebase;
return $this;
}
public function isAcceptCgu(): ?bool
{
return $this->acceptCgu;
}
public function setAcceptCgu(?bool $acceptCgu): self
{
$this->acceptCgu = $acceptCgu;
return $this;
}
public function getUuid(): ?Uuid
{
return $this->uuid;
}
public function setUuid(Uuid $uuid): self
{
$this->uuid = $uuid;
return $this;
}
/**
* @return Collection<int, OAuth2UserConsent>
*/
public function getOAuth2UserConsents(): Collection
{
return $this->oAuth2UserConsents;
}
public function addOAuth2UserConsent(OAuth2UserConsent $oAuth2UserConsent): self
{
if (!$this->oAuth2UserConsents->contains($oAuth2UserConsent)) {
$this->oAuth2UserConsents->add($oAuth2UserConsent);
$oAuth2UserConsent->setUser($this);
}
return $this;
}
public function removeOAuth2UserConsent(OAuth2UserConsent $oAuth2UserConsent): self
{
if ($this->oAuth2UserConsents->removeElement($oAuth2UserConsent)) {
// set the owning side to null (unless already changed)
if ($oAuth2UserConsent->getUser() === $this) {
$oAuth2UserConsent->setUser(null);
}
}
return $this;
}
public function canAccessBO(): bool
{
return
$this->hasRole(User::ROLE_SUPER_ADMIN) ||
$this->hasRole(User::ROLE_ADMIN) ||
$this->hasRole(User::ROLE_DIRECTEUR) ||
$this->hasRole(User::ROLE_CHEF_REDACTEUR) ||
$this->hasRole(User::ROLE_ADJOINT_REDACTEUR) ||
$this->hasRole(User::ROLE_CHEF_RUBRIQUE) ||
$this->hasRole(User::ROLE_REDACTEUR);
}
/**
* @return Collection<int, BlogPost>
*/
public function getBlogPosts(): Collection
{
return $this->blogPosts;
}
public function addBlogPost(BlogPost $blogPost): self
{
if (!$this->blogPosts->contains($blogPost)) {
$this->blogPosts[] = $blogPost;
$blogPost->setAuthor($this);
}
return $this;
}
public function removeBlogPost(BlogPost $blogPost): self
{
if ($this->blogPosts->removeElement($blogPost)) {
// set the owning side to null (unless already changed)
if ($blogPost->getAuthor() === $this) {
$blogPost->setAuthor(null);
}
}
return $this;
}
/**
* @return Collection<int, Criteria1Item>
*/
public function getCriteria1Items(): Collection
{
return $this->criteria1Items;
}
public function getCriteria1ItemsList(): string
{
return implode(", ", $this->criteria1Items->toArray());
}
public function getCriteria1ItemsString(): string
{
$string = "[";
foreach ($this->criteria1Items as $key => $criteria) {
$string .= '"' . $criteria . '"';
if ($key < count($this->criteria1Items) - 1)
$string .= ',';
}
$string .= "]";
return $string;
}
public function addCriteria1Item(Criteria1Item $criteria1Item): self
{
if (!$this->criteria1Items->contains($criteria1Item)) {
$this->criteria1Items[] = $criteria1Item;
}
return $this;
}
/**
* @return Collection<int, Criteria2Item>
*/
public function getCriteria2Items(): Collection
{
return $this->criteria2Items;
}
public function getCriteria2ItemsList(): string
{
return implode(", ", $this->criteria2Items->toArray());
}
public function getCriteria2ItemsString(): string
{
$string = "[";
foreach ($this->criteria2Items as $key => $criteria) {
$string .= '"' . $criteria . '"';
if ($key < count($this->criteria2Items) - 1)
$string .= ',';
}
$string .= "]";
return $string;
}
public function addCriteria2Item(Criteria2Item $criteria2Item): self
{
if (!$this->criteria2Items->contains($criteria2Item)) {
$this->criteria2Items[] = $criteria2Item;
}
return $this;
}
/**
* @return Collection<int, Criteria3Item>
*/
public function getCriteria3Items(): Collection
{
return $this->criteria3Items;
}
public function getCriteria3ItemsList(): string
{
return implode(", ", $this->criteria3Items->toArray());
}
public function getCriteria3ItemsString(): string
{
$string = "[";
foreach ($this->criteria3Items as $key => $criteria) {
$string .= '"' . $criteria . '"';
if ($key < count($this->criteria3Items) - 1)
$string .= ',';
}
$string .= "]";
return $string;
}
public function addCriteria3Item(Criteria3Item $criteria3Item): self
{
if (!$this->criteria3Items->contains($criteria3Item)) {
$this->criteria3Items[] = $criteria3Item;
}
return $this;
}
/**
* @return Collection<int, Criteria4Item>
*/
public function getCriteria4Items(): Collection
{
return $this->criteria4Items;
}
public function getCriteria4ItemsList(): string
{
return implode(", ", $this->criteria4Items->toArray());
}
public function getCriteria4ItemsString(): string
{
$string = "[";
foreach ($this->criteria4Items as $key => $criteria) {
$string .= '"' . $criteria . '"';
if ($key < count($this->criteria4Items) - 1)
$string .= ',';
}
$string .= "]";
return $string;
}
public function addCriteria4Item(Criteria4Item $criteria4Item): self
{
if (!$this->criteria4Items->contains($criteria4Item)) {
$this->criteria4Items[] = $criteria4Item;
}
return $this;
}
/**
* @return Collection<int, Criteria5Item>
*/
public function getCriteria5Items(): Collection
{
return $this->criteria5Items;
}
public function getCriteria5ItemsList(): string
{
return implode(", ", $this->criteria5Items->toArray());
}
public function getCriteria5ItemsString(): string
{
$string = "[";
foreach ($this->criteria5Items as $key => $criteria) {
$string .= '"' . $criteria . '"';
if ($key < count($this->criteria5Items) - 1)
$string .= ',';
}
$string .= "]";
return $string;
}
// AVANT (bug) : public function addCriteria5Item(Criteria4Item $criteria5Item): self
public function addCriteria5Item(Criteria5Item $criteria5Item): self
{
if (!$this->criteria5Items->contains($criteria5Item)) {
$this->criteria5Items[] = $criteria5Item;
}
return $this;
}
public function getTokenFirebaseGeneratedAt(): ?\DateTimeInterface
{
return $this->firebaseTokenGeneratedAt;
}
public function setTokenFirebaseGeneratedAt(?\DateTimeInterface $firebaseTokenGeneratedAt): self
{
$this->firebaseTokenGeneratedAt = $firebaseTokenGeneratedAt;
return $this;
}
/**
* @return Collection<int, Scoring>
*/
public function getScorings(): Collection
{
return $this->scorings;
}
public function addScoring(Scoring $scoring): self
{
if (!$this->scorings->contains($scoring)) {
$this->scorings[] = $scoring;
$scoring->setUser($this);
}
return $this;
}
public function removeScoring(Scoring $scoring): self
{
if ($this->scorings->removeElement($scoring)) {
if ($scoring->getUser() === $this) {
$scoring->setUser(null);
}
}
return $this;
}
/**
* @return Collection<int, Instance>
*/
public function getInstances(): Collection
{
return $this->instances;
}
public function getInstancesList(): string
{
return implode(", ", $this->instances->toArray());
}
public function getInstancesString(): string
{
$string = "[";
foreach ($this->instances as $key => $instance) {
$string .= '"' . $instance->getName() . '"';
if ($key < count($this->instances) - 1) {
$string .= ',';
}
}
$string .= "]";
return $string;
}
public function addInstance(Instance $instance): self
{
if (!$this->instances->contains($instance)) {
$this->instances[] = $instance;
}
return $this;
}
public function removeInstance(Instance $instance): self
{
$this->instances->removeElement($instance);
return $this;
}
public function hasInstance(Instance $instance): bool
{
return $this->instances->contains($instance);
}
/**
* @return bool
*/
public function isAllowSelfEdit(): bool
{
return (bool) $this->allowSelfEdit;
}
/**
* @param bool $allowSelfEdit
* @return self
*/
public function setAllowSelfEdit(bool $allowSelfEdit): self
{
$this->allowSelfEdit = $allowSelfEdit;
return $this;
}
/**
* @return bool
*/
public function isAnonymizationEnabled(): bool
{
return $this->anonymizationEnabled;
}
/**
* @param bool $anonymizationEnabled
* @return self
*/
public function setAnonymizationEnabled(bool $anonymizationEnabled): self
{
$this->anonymizationEnabled = $anonymizationEnabled;
return $this;
}
/**
* @return
*/
public function getFirstName(): ?string
{
return $this->firstName;
}
/**
* @param $firstName
* @return self
*/
public function setFirstName(?string $firstName): self
{
$this->firstName = $firstName;
return $this;
}
/**
* @return
*/
public function getLastName(): ?string
{
return $this->lastName;
}
/**
* @param $lastName
* @return self
*/
public function setLastName(?string $lastName): self
{
$this->lastName = $lastName;
return $this;
}
/**
* @return
*/
public function getEntityCode(): ?string
{
return $this->entityCode;
}
/**
* @param $entityCode
* @return self
*/
public function setEntityCode(?string $entityCode): self
{
$this->entityCode = $entityCode;
return $this;
}
/**
* @return
*/
public function getPhotoPath(): ?string
{
return $this->photoPath;
}
/**
* @param $photoPath
* @return self
*/
public function setPhotoPath(?string $photoPath): self
{
$this->photoPath = $photoPath;
return $this;
}
/**
* @return
*/
public function getProEmail(): ?string
{
return $this->proEmail;
}
/**
* @param $proEmail
* @return self
*/
public function setProEmail(?string $proEmail): self
{
$this->proEmail = $proEmail;
return $this;
}
/**
* @return
*/
public function getProPhone(): ?string
{
return $this->proPhone;
}
/**
* @param $proPhone
* @return self
*/
public function setProPhone(?string $proPhone): self
{
$this->proPhone = $proPhone;
return $this;
}
public function isAcceptPrivacy(): bool
{
return $this->acceptPrivacy;
}
public function setAcceptPrivacy(bool $acceptPrivacy): self
{
$this->acceptPrivacy = $acceptPrivacy;
return $this;
}
public function getAcceptPrivacyAt(): ?DateTimeImmutable
{
return $this->acceptPrivacyAt;
}
public function setAcceptPrivacyAt(?DateTimeImmutable $acceptPrivacyAt): self
{
$this->acceptPrivacyAt = $acceptPrivacyAt;
return $this;
}
public function getAcceptPrivacyVersion(): ?string
{
return $this->acceptPrivacyVersion;
}
public function setAcceptPrivacyVersion(?string $acceptPrivacyVersion): self
{
$this->acceptPrivacyVersion = $acceptPrivacyVersion;
return $this;
}
public function isPrivacyChecked(): bool
{
return $this->privacyChecked;
}
public function setPrivacyChecked(bool $value): self
{
$this->privacyChecked = $value;
return $this;
}
#[Assert\Callback(groups: ['identity'])]
public function validateIdentity(ExecutionContextInterface $context): void
{
// Si l’admin coche "Autoriser l’utilisateur à compléter/modifier ses infos"
// => on n'impose pas les champs d’identité côté back-office.
if ($this->isAllowSelfEdit() || $this->isAnonymizationEnabled()) {
return;
}
// Sinon : ces champs deviennent obligatoires côté admin
$lastName = trim((string) $this->getLastName());
$firstName = trim((string) $this->getFirstName());
$entity = trim((string) $this->getEntityCode());
if ($lastName === '') {
$context->buildViolation('Le nom est obligatoire.')
->atPath('lastName')
->addViolation();
}
if ($firstName === '') {
$context->buildViolation('Le prénom est obligatoire.')
->atPath('firstName')
->addViolation();
}
if ($entity === '') {
$context->buildViolation('L’entité / code entité est obligatoire.')
->atPath('entityCode')
->addViolation();
}
}
// Criteria 1
public function removeCriteria1Item(Criteria1Item $criteria1Item): self
{
$this->criteria1Items->removeElement($criteria1Item);
return $this;
}
// Criteria 2
public function removeCriteria2Item(Criteria2Item $criteria2Item): self
{
$this->criteria2Items->removeElement($criteria2Item);
return $this;
}
// Criteria 3
public function removeCriteria3Item(Criteria3Item $criteria3Item): self
{
$this->criteria3Items->removeElement($criteria3Item);
return $this;
}
// Criteria 4
public function removeCriteria4Item(Criteria4Item $criteria4Item): self
{
$this->criteria4Items->removeElement($criteria4Item);
return $this;
}
// Criteria 5
public function removeCriteria5Item(Criteria5Item $criteria5Item): self
{
$this->criteria5Items->removeElement($criteria5Item);
return $this;
}
}