| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299 |
- <?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 App\Entity\Place\Place;
- use DH\Auditor\Provider\Doctrine\Auditing\Annotation\Auditable;
- use JetBrains\PhpStorm\Pure;
- 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;
- use App\Validator\Core as OpentalentAssert;
- /**
- * Données de contact d'une Person ou d'une Organization ou d'un lieu
- */
- #[Auditable]
- #[ApiResource(
- itemOperations: [
- 'get' => [
- 'security' => 'is_granted("CONTACT_POINT_READ", object)'
- ],
- 'put' => [
- 'security' => 'is_granted("CONTACT_POINT_EDIT", object)'
- ],
- 'delete' => [
- 'security' => 'is_granted("CONTACT_POINT_DELETE", object)'
- ]
- ]
- )]
- #[ORM\Entity(repositoryClass: ContactPointRepository::class)]
- #[OpentalentAssert\ContactPoint]
- class ContactPoint
- {
- #[ORM\Id]
- #[ORM\Column]
- #[ORM\GeneratedValue]
- private ?int $id = null;
- #[ORM\Column(length: 255)]
- #[Assert\Choice(callback: ['\App\Enum\Core\ContactPointTypeEnum', 'toArray'], message: 'invalid-contact-type')]
- private string $contactType;
- #[ORM\Column(length: 255, nullable: true)]
- #[Assert\Email(message: 'invalid-email-format', mode: 'strict')]
- private ?string $email = null;
- #[ORM\Column(length: 255, nullable: true)]
- private ?string $emailInvalid = null;
- #[ORM\Column(type: 'phone_number', nullable: true)]
- private ?PhoneNumber $faxNumber = null;
- #[ORM\Column(length: 255, nullable: true)]
- private ?string $faxNumberInvalid = null;
- #[ORM\Column(type: 'phone_number', nullable: true)]
- private ?PhoneNumber $telphone = null;
- #[ORM\Column(length: 255, nullable: true)]
- private ?string $telphoneInvalid = null;
- #[ORM\Column(type: 'phone_number', nullable: true)]
- private ?PhoneNumber $mobilPhone = null;
- #[ORM\Column(length: 255, nullable: true)]
- private ?string $mobilPhoneInvalid = null;
- #[ORM\ManyToMany(targetEntity: Organization::class, inversedBy: 'contactPoints')]
- #[ORM\JoinTable(name: 'organization_contactpoint')]
- #[ORM\JoinColumn(name: 'contactPoint_id', referencedColumnName: 'id', unique: true)]
- #[ORM\InverseJoinColumn(name: 'organization_id', referencedColumnName: 'id')]
- private Collection $organization;
- #[ORM\ManyToMany(targetEntity: Person::class ,inversedBy: 'contactPoints')]
- #[ORM\JoinTable(name: 'person_contactpoint')]
- #[ORM\JoinColumn(name: 'contactPoint_id', referencedColumnName: 'id', unique: true)]
- #[ORM\InverseJoinColumn(name: 'person_id', referencedColumnName: 'id')]
- private Collection $person;
- #[ORM\ManyToMany(targetEntity: Place::class, mappedBy: 'contactpoint')]
- #[ORM\JoinTable(name: 'place_contactpoint')]
- #[ORM\JoinColumn(name: 'contactPoint_id', referencedColumnName: 'id', unique: true)]
- #[ORM\InverseJoinColumn(name: 'place_id', referencedColumnName: 'id')]
- private $place;
- #[Pure] public function __construct()
- {
- $this->organization = new ArrayCollection();
- $this->person = new ArrayCollection();
- $this->place = 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;
- }
- public function getOrganization(): Collection
- {
- return $this->organization;
- }
- public function addOrganization(Organization $organization): self
- {
- if (!$this->organization->contains($organization)) {
- $this->organization[] = $organization;
- $organization->addContactPoint($this);
- }
- return $this;
- }
- public function removeOrganization(Organization $organization): self
- {
- if ($this->organization->removeElement($organization)) {
- $organization->removeContactPoint($this);
- }
- return $this;
- }
- public function getPerson(): Collection
- {
- return $this->person;
- }
- public function addPerson(Person $person): self
- {
- if (!$this->person->contains($person)) {
- $this->person[] = $person;
- $person->addContactPoint($this);
- }
- return $this;
- }
- public function removePerson(Person $person): self
- {
- if ($this->person->removeElement($person)) {
- $person->removeContactPoint($this);
- }
- return $this;
- }
- /**
- * @return Collection<int, Place>
- */
- public function getPlace(): Collection
- {
- return $this->place;
- }
- public function addPlace(Place $place): self
- {
- if (!$this->place->contains($place)) {
- $this->place[] = $place;
- $place->addContactpoint($this);
- }
- return $this;
- }
- public function removePlace(Place $place): self
- {
- if ($this->place->removeElement($place)) {
- $place->removeContactpoint($this);
- }
- return $this;
- }
- }
|