|
|
@@ -0,0 +1,273 @@
|
|
|
+<?php
|
|
|
+declare(strict_types=1);
|
|
|
+
|
|
|
+namespace App\Entity\Core;
|
|
|
+
|
|
|
+use ApiPlatform\Core\Annotation\ApiResource;
|
|
|
+use App\Entity\Organization\Organization;
|
|
|
+use App\Entity\Person\Person;
|
|
|
+use libphonenumber\PhoneNumber;
|
|
|
+use App\Repository\Core\ContactPointRepository;
|
|
|
+use Doctrine\Common\Collections\ArrayCollection;
|
|
|
+use Doctrine\Common\Collections\Collection;
|
|
|
+use Doctrine\ORM\Mapping as ORM;
|
|
|
+use Symfony\Component\Validator\Constraints as Assert;
|
|
|
+
|
|
|
+/**
|
|
|
+ * Données de contact d'une Person ou d'une Organization ou d'un lieu
|
|
|
+ * @ApiResource(
|
|
|
+ * itemOperations={
|
|
|
+ * "get"={"security"="is_granted('CONTACT_POINT_READ', object)"},
|
|
|
+ * "put"={"security"="is_granted('CONTACT_POINT_EDIT', object)"},
|
|
|
+ * }
|
|
|
+ * )
|
|
|
+ * @ORM\Entity(repositoryClass=ContactPointRepository::class)
|
|
|
+ */
|
|
|
+class ContactPoint
|
|
|
+{
|
|
|
+ /**
|
|
|
+ * @ORM\Id
|
|
|
+ * @ORM\GeneratedValue
|
|
|
+ * @ORM\Column(type="integer")
|
|
|
+ */
|
|
|
+ private $id;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @ORM\Column(type="string", length=255)
|
|
|
+ * @Assert\Choice(callback={"\App\Enum\Core\ContactPointTypeEnum", "toArray"}, message="invalid-choice")
|
|
|
+ */
|
|
|
+ private $contactType;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @ORM\Column(type="string", length=255, nullable=true)
|
|
|
+ * @Assert\Email(mode="strict", message="invalid-email-format")
|
|
|
+ * @Assert\Regex(pattern="/^[a-zA-Z0-9._%-]{1,64}@[a-zA-Z0-9.-]{2,249}\.[a-zA-Z]{2,6}$/", message="email-error")
|
|
|
+ */
|
|
|
+ private $email;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @ORM\Column(type="string", length=255, nullable=true)
|
|
|
+ */
|
|
|
+ private $emailInvalid;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @ORM\Column(type="phone_number", nullable=true)
|
|
|
+ */
|
|
|
+ private $faxNumber;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @ORM\Column(type="string", length=255, nullable=true)
|
|
|
+ */
|
|
|
+ private $faxNumberInvalid;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @ORM\Column(type="phone_number", nullable=true)
|
|
|
+ */
|
|
|
+ private $telphone;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @ORM\Column(type="string", length=255, nullable=true)
|
|
|
+ */
|
|
|
+ private $telphoneInvalid;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @ORM\Column(type="phone_number", nullable=true)
|
|
|
+ */
|
|
|
+ private $mobilPhone;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @ORM\Column(type="string", length=255, nullable=true)
|
|
|
+ */
|
|
|
+ private $mobilPhoneInvalid;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @ORM\ManyToMany(targetEntity=Organization::class, inversedBy="contactPoints")
|
|
|
+ * @ORM\JoinTable(name="organization_contactpoint")
|
|
|
+ */
|
|
|
+ private $organization;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @ORM\ManyToMany(targetEntity=Person::class, inversedBy="contactPoints")
|
|
|
+ * @ORM\JoinTable(name="person_contactpoint")
|
|
|
+ */
|
|
|
+ private $person;
|
|
|
+
|
|
|
+ public function __construct()
|
|
|
+ {
|
|
|
+ $this->organization = new ArrayCollection();
|
|
|
+ $this->person = new ArrayCollection();
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getId(): ?int
|
|
|
+ {
|
|
|
+ return $this->id;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getContactType(): ?string
|
|
|
+ {
|
|
|
+ return $this->contactType;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function setContactType(string $contactType): self
|
|
|
+ {
|
|
|
+ $this->contactType = $contactType;
|
|
|
+
|
|
|
+ return $this;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getEmail(): ?string
|
|
|
+ {
|
|
|
+ return $this->email;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function setEmail(?string $email): self
|
|
|
+ {
|
|
|
+ $this->email = $email;
|
|
|
+
|
|
|
+ if(!is_null($this->email && !is_null($this->getEmailInvalid())))
|
|
|
+ $this->setEmailInvalid(null);
|
|
|
+
|
|
|
+ return $this;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getEmailInvalid(): ?string
|
|
|
+ {
|
|
|
+ return $this->emailInvalid;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function setEmailInvalid(?string $emailInvalid): self
|
|
|
+ {
|
|
|
+ $this->emailInvalid = $emailInvalid;
|
|
|
+
|
|
|
+ return $this;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getFaxNumber(): ?PhoneNumber
|
|
|
+ {
|
|
|
+ return $this->faxNumber;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function setFaxNumber(?PhoneNumber $faxNumber): self
|
|
|
+ {
|
|
|
+ $this->faxNumber = $faxNumber;
|
|
|
+
|
|
|
+ if(!is_null($this->faxNumber && !is_null($this->getFaxNumberInvalid())))
|
|
|
+ $this->setFaxNumberInvalid(null);
|
|
|
+
|
|
|
+ return $this;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getFaxNumberInvalid(): ?string
|
|
|
+ {
|
|
|
+ return $this->faxNumberInvalid;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function setFaxNumberInvalid(?string $faxNumberInvalid): self
|
|
|
+ {
|
|
|
+ $this->faxNumberInvalid = $faxNumberInvalid;
|
|
|
+
|
|
|
+ return $this;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getTelphone(): ?PhoneNumber
|
|
|
+ {
|
|
|
+ return $this->telphone;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function setTelphone(?PhoneNumber $telphone): self
|
|
|
+ {
|
|
|
+ $this->telphone = $telphone;
|
|
|
+
|
|
|
+ if(!is_null($this->telphone && !is_null($this->getTelphoneInvalid())))
|
|
|
+ $this->setTelphoneInvalid(null);
|
|
|
+
|
|
|
+ return $this;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getTelphoneInvalid(): ?string
|
|
|
+ {
|
|
|
+ return $this->telphoneInvalid;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function setTelphoneInvalid(?string $telphoneInvalid): self
|
|
|
+ {
|
|
|
+ $this->telphoneInvalid = $telphoneInvalid;
|
|
|
+
|
|
|
+ return $this;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getMobilPhone(): ?PhoneNumber
|
|
|
+ {
|
|
|
+ return $this->mobilPhone;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function setMobilPhone(?PhoneNumber $mobilPhone): self
|
|
|
+ {
|
|
|
+ $this->mobilPhone = $mobilPhone;
|
|
|
+
|
|
|
+ if(!is_null($this->mobilPhone && !is_null($this->getMobilPhoneInvalid())))
|
|
|
+ $this->setMobilPhoneInvalid(null);
|
|
|
+
|
|
|
+ return $this;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getMobilPhoneInvalid(): ?string
|
|
|
+ {
|
|
|
+ return $this->mobilPhoneInvalid;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function setMobilPhoneInvalid(?string $mobilPhoneInvalid): self
|
|
|
+ {
|
|
|
+ $this->mobilPhoneInvalid = $mobilPhoneInvalid;
|
|
|
+
|
|
|
+ return $this;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @return Collection|Organization[]
|
|
|
+ */
|
|
|
+ public function getOrganization(): Collection
|
|
|
+ {
|
|
|
+ return $this->organization;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function addOrganization(Organization $organization): self
|
|
|
+ {
|
|
|
+ if (!$this->organization->contains($organization)) {
|
|
|
+ $this->organization[] = $organization;
|
|
|
+ }
|
|
|
+
|
|
|
+ return $this;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function removeOrganization(Organization $organization): self
|
|
|
+ {
|
|
|
+ $this->organization->removeElement($organization);
|
|
|
+
|
|
|
+ return $this;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @return Collection|Person[]
|
|
|
+ */
|
|
|
+ public function getPerson(): Collection
|
|
|
+ {
|
|
|
+ return $this->person;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function addPerson(Person $person): self
|
|
|
+ {
|
|
|
+ if (!$this->person->contains($person)) {
|
|
|
+ $this->person[] = $person;
|
|
|
+ }
|
|
|
+
|
|
|
+ return $this;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function removePerson(Person $person): self
|
|
|
+ {
|
|
|
+ $this->person->removeElement($person);
|
|
|
+
|
|
|
+ return $this;
|
|
|
+ }
|
|
|
+}
|