| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616 |
- <?php
- declare(strict_types=1);
- namespace App\Entity\Person;
- use ApiPlatform\Metadata\ApiResource;
- use App\Entity\Access\Access;
- use App\Entity\AccessWish\DocumentWish;
- use App\Entity\Core\BankAccount;
- use App\Entity\Core\ContactPoint;
- use App\Entity\Core\Country;
- use App\Entity\Core\File;
- use App\Enum\Person\GenderEnum;
- use App\Repository\Person\PersonRepository;
- // use DH\Auditor\Provider\Doctrine\Auditing\Annotation\Auditable;
- use Doctrine\Common\Collections\ArrayCollection;
- use Doctrine\Common\Collections\Collection;
- use Doctrine\ORM\Mapping as ORM;
- use JetBrains\PhpStorm\Pure;
- use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
- use Symfony\Component\Security\Core\User\UserInterface;
- use Symfony\Component\Serializer\Annotation\Groups;
- /**
- * Personne physique ou morale.
- */
- #[ApiResource(operations: [])]
- // #[Auditable]
- #[ORM\Entity(repositoryClass: PersonRepository::class)]
- class Person implements UserInterface, PasswordAuthenticatedUserInterface
- {
- #[ORM\Id]
- #[ORM\Column]
- #[ORM\GeneratedValue]
- #[Groups(['access_people_ref'])]
- private ?int $id = null;
- #[ORM\Column(length: 180, unique: true, nullable: true)]
- private ?string $username = null;
- /**
- * @var array<mixed>|null
- */
- #[ORM\Column(type: "array", nullable: true)]
- private ?array $roles = [];
- #[ORM\Column(nullable: true)]
- private ?string $password = null;
- #[ORM\Column(length: 255, nullable: true)]
- #[Groups(['access_people_ref', 'access_address'])]
- private ?string $name = null;
- #[ORM\Column(length: 255, nullable: true)]
- #[Groups(['access_people_ref', 'access_address'])]
- private ?string $givenName = null;
- #[ORM\ManyToMany(targetEntity: ContactPoint::class, mappedBy: 'person')]
- private Collection $contactPoints;
- #[ORM\ManyToMany(targetEntity: BankAccount::class, inversedBy: 'person', cascade: ['persist'], orphanRemoval: true)]
- #[ORM\JoinColumn(name: 'person_id', referencedColumnName: 'id')]
- #[ORM\InverseJoinColumn(name: 'bankAccount_id', referencedColumnName: 'id')]
- private Collection $bankAccount;
- #[ORM\OneToMany(mappedBy: 'person', targetEntity: PersonAddressPostal::class, cascade: ['persist', 'remove'], orphanRemoval: true)]
- #[Groups('access_address')]
- private Collection $personAddressPostal;
- #[ORM\Column(length: 50, nullable: true, enumType: GenderEnum::class)]
- private ?GenderEnum $gender = null;
- #[ORM\ManyToOne(inversedBy: 'personImages')]
- #[ORM\JoinColumn(referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
- private ?File $image = null;
- #[ORM\Column(options: ['default' => true])]
- private bool $isPhysical = true;
- #[ORM\ManyToOne]
- private Country $nationality;
- #[ORM\OneToMany(mappedBy: 'person', targetEntity: Access::class, orphanRemoval: true)]
- private Collection $access;
- #[ORM\OneToMany(mappedBy: 'person', targetEntity: File::class, orphanRemoval: true)]
- private Collection $files;
- #[ORM\OneToMany(mappedBy: 'person', targetEntity: DisciplineOtherEstablishment::class, cascade: ['persist', 'remove'], orphanRemoval: true)]
- private Collection $disciplineotherestablishments;
- #[ORM\OneToMany(mappedBy: 'person', targetEntity: Qualification::class, cascade: ['persist', 'remove'], orphanRemoval: true)]
- private Collection $qualifications;
- #[ORM\OneToMany(mappedBy: 'person', targetEntity: SchoolingInEstablishment::class, cascade: ['persist', 'remove'], orphanRemoval: true)]
- private Collection $schoolingEstablisments;
- #[ORM\OneToMany(mappedBy: 'person', targetEntity: TeacherSchoolingHistory::class, cascade: ['persist', 'remove'], orphanRemoval: true)]
- private Collection $teacherSchoolingHistories;
- #[ORM\ManyToMany(targetEntity: File::class, mappedBy: 'accessPersons', cascade: ['persist', 'remove'])]
- #[ORM\OrderBy(['id' => 'DESC'])]
- private Collection $personFiles;
- #[ORM\OneToMany(mappedBy: 'personOwner', targetEntity: DocumentWish::class, cascade: ['persist', 'remove'], orphanRemoval: true)]
- private Collection $documentWishes;
- /** @var array<string, string> */
- #[ORM\Column(type: "json", nullable: true)]
- private array $confidentiality = [];
- #[Pure]
- public function __construct()
- {
- $this->contactPoints = new ArrayCollection();
- $this->personAddressPostal = new ArrayCollection();
- $this->bankAccount = new ArrayCollection();
- $this->access = new ArrayCollection();
- $this->files = new ArrayCollection();
- $this->disciplineotherestablishments = new ArrayCollection();
- $this->qualifications = new ArrayCollection();
- $this->schoolingEstablisments = new ArrayCollection();
- $this->teacherSchoolingHistories = new ArrayCollection();
- $this->personFiles = new ArrayCollection();
- $this->documentWishes = new ArrayCollection();
- }
- public function getId(): ?int
- {
- return $this->id;
- }
- public function getUsername(): ?string
- {
- return (string) $this->username;
- }
- public function getUserIdentifier(): string
- {
- return (string) $this->username;
- }
- public function setUsername(?string $username): self
- {
- $this->username = $username;
- return $this;
- }
- /**
- * @return string[]
- */
- public function getRoles(): array
- {
- $roles = $this->roles;
- // guarantee every user at least has ROLE_USER
- $roles[] = 'ROLE_USER';
- return array_unique($roles);
- }
- /**
- * @param string[] $roles
- *
- * @return $this
- */
- public function setRoles(array $roles): self
- {
- $this->roles = $roles;
- return $this;
- }
- public function getPassword(): ?string
- {
- return (string) $this->password;
- }
- public function setPassword(?string $password): self
- {
- $this->password = $password;
- return $this;
- }
- public function getSalt(): ?string
- {
- return null;
- // not needed when using the "bcrypt" algorithm in security.yaml
- }
- public function eraseCredentials(): void
- {
- // If you store any temporary, sensitive data on the user, clear it here
- // $this->plainPassword = null;
- }
- public function getName(): ?string
- {
- return $this->name;
- }
- public function setName(?string $name): self
- {
- $this->name = $name;
- return $this;
- }
- public function getGivenName(): ?string
- {
- return $this->givenName;
- }
- public function setGivenName(?string $givenName): self
- {
- $this->givenName = $givenName;
- return $this;
- }
- public function getFullName(): ?string
- {
- if (!$this->getName() || !$this->getGivenName()) {
- return null;
- }
- return "{$this->getName()} {$this->getGivenName()}";
- }
- public function setGender(?GenderEnum $gender): self
- {
- $this->gender = $gender;
- return $this;
- }
- public function getGender(): ?GenderEnum
- {
- return $this->gender;
- }
- public function getContactPoints(): Collection
- {
- return $this->contactPoints;
- }
- public function addContactPoint(ContactPoint $contactPoint): self
- {
- if (!$this->contactPoints->contains($contactPoint)) {
- $this->contactPoints[] = $contactPoint;
- $contactPoint->addPerson($this);
- }
- return $this;
- }
- public function removeContactPoint(ContactPoint $contactPoint): self
- {
- if ($this->contactPoints->removeElement($contactPoint)) {
- $contactPoint->removePerson($this);
- }
- return $this;
- }
- public function setImage(?File $image): self
- {
- $this->image = $image;
- return $this;
- }
- public function getImage(): ?File
- {
- return $this->image;
- }
- public function getPersonAddressPostal(): Collection
- {
- return $this->personAddressPostal;
- }
- public function addPersonAddressPostal(PersonAddressPostal $personAddressPostal): self
- {
- if (!$this->personAddressPostal->contains($personAddressPostal)) {
- $this->personAddressPostal[] = $personAddressPostal;
- $personAddressPostal->setPerson($this);
- }
- return $this;
- }
- public function removePersonAddressPostal(PersonAddressPostal $personAddressPostal): self
- {
- if ($this->personAddressPostal->removeElement($personAddressPostal)) {
- // set the owning side to null (unless already changed)
- if ($personAddressPostal->getPerson() === $this) {
- $personAddressPostal->setPerson(null);
- }
- }
- return $this;
- }
- public function getIsPhysical(): ?bool
- {
- return $this->isPhysical;
- }
- public function setAdminAccess(bool $isPhysical): self
- {
- $this->isPhysical = $isPhysical;
- return $this;
- }
- public function setIsPhysical(bool $isPhysical): self
- {
- $this->isPhysical = $isPhysical;
- return $this;
- }
- /**
- * @return Collection<int, BankAccount>
- */
- public function getBankAccount(): Collection
- {
- return $this->bankAccount;
- }
- public function addBankAccount(BankAccount $bankAccount): self
- {
- if (!$this->bankAccount->contains($bankAccount)) {
- $this->bankAccount[] = $bankAccount;
- }
- return $this;
- }
- public function removeBankAccount(BankAccount $bankAccount): self
- {
- $this->bankAccount->removeElement($bankAccount);
- return $this;
- }
- public function getNationality(): ?Country
- {
- return $this->nationality;
- }
- public function setNationality(?Country $nationality): self
- {
- $this->nationality = $nationality;
- return $this;
- }
- /**
- * @return Collection<int, Access>
- */
- public function getAccesses(): Collection
- {
- return $this->access;
- }
- public function addAccess(Access $access): self
- {
- if (!$this->access->contains($access)) {
- $this->access[] = $access;
- $access->setPerson($this);
- }
- return $this;
- }
- public function removeAccess(Access $access): self
- {
- if ($this->access->removeElement($access)) {
- // set the owning side to null (unless already changed)
- if ($access->getPerson() === $this) {
- $access->setPerson(null);
- }
- }
- return $this;
- }
- /**
- * @return Collection<int, File>
- */
- public function getFiles(): Collection
- {
- return $this->files;
- }
- public function addFile(File $file): self
- {
- if (!$this->files->contains($file)) {
- $this->files[] = $file;
- $file->setPerson($this);
- }
- return $this;
- }
- public function removeFile(File $file): self
- {
- if ($this->files->removeElement($file)) {
- // set the owning side to null (unless already changed)
- if ($file->getPerson() === $this) {
- $file->setPerson(null);
- }
- }
- return $this;
- }
- /**
- * @return Collection<int, DisciplineOtherEstablishment>
- */
- public function getDisciplineotherestablishments(): Collection
- {
- return $this->disciplineotherestablishments;
- }
- public function addDisciplineotherestablishment(DisciplineOtherEstablishment $disciplineotherestablishment): self
- {
- if (!$this->disciplineotherestablishments->contains($disciplineotherestablishment)) {
- $this->disciplineotherestablishments[] = $disciplineotherestablishment;
- $disciplineotherestablishment->setPerson($this);
- }
- return $this;
- }
- public function removeDisciplineotherestablishment(DisciplineOtherEstablishment $disciplineotherestablishment): self
- {
- if ($this->disciplineotherestablishments->removeElement($disciplineotherestablishment)) {
- // set the owning side to null (unless already changed)
- if ($disciplineotherestablishment->getPerson() === $this) {
- $disciplineotherestablishment->setPerson(null);
- }
- }
- return $this;
- }
- /**
- * @return Collection<int, Qualification>
- */
- public function getQualifications(): Collection
- {
- return $this->qualifications;
- }
- public function addQualification(Qualification $qualification): self
- {
- if (!$this->qualifications->contains($qualification)) {
- $this->qualifications[] = $qualification;
- $qualification->setPerson($this);
- }
- return $this;
- }
- public function removeQualification(Qualification $qualification): self
- {
- if ($this->qualifications->removeElement($qualification)) {
- // set the owning side to null (unless already changed)
- if ($qualification->getPerson() === $this) {
- $qualification->setPerson(null);
- }
- }
- return $this;
- }
- /**
- * @return Collection<int, SchoolingInEstablishment>
- */
- public function getSchoolingEstablisments(): Collection
- {
- return $this->schoolingEstablisments;
- }
- public function addSchoolingEstablisment(SchoolingInEstablishment $schoolingEstablisment): self
- {
- if (!$this->schoolingEstablisments->contains($schoolingEstablisment)) {
- $this->schoolingEstablisments[] = $schoolingEstablisment;
- $schoolingEstablisment->setPerson($this);
- }
- return $this;
- }
- public function removeSchoolingEstablisment(SchoolingInEstablishment $schoolingEstablisment): self
- {
- if ($this->schoolingEstablisments->removeElement($schoolingEstablisment)) {
- // set the owning side to null (unless already changed)
- if ($schoolingEstablisment->getPerson() === $this) {
- $schoolingEstablisment->setPerson(null);
- }
- }
- return $this;
- }
- /**
- * @return Collection<int, TeacherSchoolingHistory>
- */
- public function getTeacherSchoolingHistories(): Collection
- {
- return $this->teacherSchoolingHistories;
- }
- public function addTeacherSchoolingHistory(TeacherSchoolingHistory $teacherSchoolingHistory): self
- {
- if (!$this->teacherSchoolingHistories->contains($teacherSchoolingHistory)) {
- $this->teacherSchoolingHistories[] = $teacherSchoolingHistory;
- $teacherSchoolingHistory->setPerson($this);
- }
- return $this;
- }
- public function removeTeacherSchoolingHistory(TeacherSchoolingHistory $teacherSchoolingHistory): self
- {
- if ($this->teacherSchoolingHistories->removeElement($teacherSchoolingHistory)) {
- // set the owning side to null (unless already changed)
- if ($teacherSchoolingHistory->getPerson() === $this) {
- $teacherSchoolingHistory->setPerson(null);
- }
- }
- return $this;
- }
- /**
- * @return Collection<int, File>
- */
- public function getPersonFiles(): Collection
- {
- return $this->personFiles;
- }
- public function addPersonFile(File $personFile): self
- {
- if (!$this->personFiles->contains($personFile)) {
- $this->personFiles[] = $personFile;
- $personFile->addAccessPerson($this);
- }
- return $this;
- }
- public function removePersonFile(File $personFile): self
- {
- if ($this->personFiles->removeElement($personFile)) {
- $personFile->removeAccessPerson($this);
- }
- return $this;
- }
- /**
- * @return Collection<int, DocumentWish>
- */
- public function getDocumentWishes(): Collection
- {
- return $this->documentWishes;
- }
- public function addDocumentWish(DocumentWish $documentWish): self
- {
- if (!$this->documentWishes->contains($documentWish)) {
- $this->documentWishes[] = $documentWish;
- $documentWish->setPersonOwner($this);
- }
- return $this;
- }
- public function removeDocumentWish(DocumentWish $documentWish): self
- {
- if ($this->documentWishes->removeElement($documentWish)) {
- // set the owning side to null (unless already changed)
- if ($documentWish->getPersonOwner() === $this) {
- $documentWish->setPersonOwner(null);
- }
- }
- return $this;
- }
- /**
- * @return array<string, string>
- */
- public function getConfidentiality(): array
- {
- return $this->confidentiality;
- }
- /**
- * @param array<string, string> $confidentiality
- * @return $this
- */
- public function setConfidentiality(array $confidentiality): self
- {
- $this->confidentiality = $confidentiality;
- return $this;
- }
- }
|