| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710 |
- <?php
- namespace AppBundle\Entity\Core;
- use AppBundle\Annotation\ExportFilter;
- use AppBundle\Annotation\ExportSplitFields;
- use AppBundle\Entity\Organization\Organization;
- use AppBundle\Entity\Person\Person;
- use AppBundle\Entity\Place\Place;
- use AppBundle\Enum\Core\ContactPointTypeEnum;
- use Doctrine\ORM\Mapping as ORM;
- use Dunglas\ApiBundle\Annotation\Iri;
- use libphonenumber\PhoneNumber;
- use libphonenumber\PhoneNumberUtil;
- use Symfony\Component\Serializer\Annotation\Groups;
- use Symfony\Component\Validator\Constraints as Assert;
- use AppBundle\Entity\Traits\TimestampableEntity;
- use AppBundle\Entity\Traits\CreatorUpdaterEntity;
- use AppBundle\Validator\Constraints as OpentalentAssert;
- use AppBundle\Annotation\Confidentiality;
- use Misd\PhoneNumberBundle\Validator\Constraints\PhoneNumber as AssertPhoneNumber;
- /**
- * Données de contact d'une Person ou d'une Organization
- *
- * @Iri("http://schema.org/ContactPoint")
- */
- #[ORM\Entity(repositoryClass: 'AppBundle\Entity\Core\Repository\ContactPointRepository')]
- #[Assert\Callback(['AppBundle\Validator\Constraints\Core\ContactPointValidator', 'validate'])]
- #[ORM\Table(name: 'ContactPoint')]
- #[ORM\Index(name: 'email', columns: ['email'])]
- class ContactPoint
- {
- use TimestampableEntity;
- use CreatorUpdaterEntity;
- /**
- * @var int
- *
- * })
- */
- #[ORM\Column(type: 'integer')]
- #[ORM\Id]
- #[ORM\GeneratedValue(strategy: 'AUTO')]
- #[Groups(['contactpoint', 'othercontact_list_person', 'place_list', 'student_registration_person', 'student_registration_guardians', 'network_list', 'federations_list', 'networkmanagers_list_person', 'network_artist_school_list', 'organization_details', 'organization_cotisation_steps', 'online_registration_access_details_person', 'cmf_network_organizations'])]
- private $id;
- /**
- * @var string A person or organization can have different contact points, for different purposes. For example, a sales contact point, a PR contact point and so on. This property is used to specify the kind of contact point.
- *
- * @Iri("https://schema.org/contactType")
- */
- #[ORM\Column(type: 'string')]
- #[Assert\Type(type: 'string')]
- #[Assert\NotBlank(message: 'not-blank')]
- #[Assert\Choice(callback: ['\AppBundle\Enum\Core\ContactPointTypeEnum', 'toArray'], message: 'invalid-choice')]
- #[Groups(['contactpoint', 'access_details_person', 'access_details_guardians', 'report_card_person', 'report_card_guardians', 'student_registration_person', 'student_registration_guardians', 'network_list_contactpoint', 'federations_list_contactpoint', 'networkmanagers_list_person', 'network_artist_school_list_contactpoint', 'network_list_adminaccess', 'access_mail_person', 'student_list_guardians', 'access_mail_guardians', 'organization_details_contactpoint', 'payer_list_person', 'access_duplicate_control_list_person', 'organization_cotisation_steps_contactpoint', 'template', 'view_from_manager_create_person', 'online_registration_access_details_person', 'onlineregistration_infos_organization', 'accesses_no_reregistred_list_person', 'accesses_no_reregistred_list_guardians', 'cmf_network_organizations_contactpoint'])]
- private $contactType;
- /**
- * @var string Email address.
- *
- * @Iri("https://schema.org/email")
- * @Confidentiality(visibility=\AppBundle\Enum\Confidentiality\ConfidentialityTypeEnum::VISIBILITY_ORGANIZATION)
- */
- #[ORM\Column(type: 'string', length: 255, nullable: true)]
- #[Assert\Email(strict: true, message: 'invalid-email-format')]
- #[Assert\Email(checkMX: true, message: 'invalid-email-domain')]
- #[Assert\Regex(pattern: '/^[a-zA-Z0-9._%-]{1,64}@[a-zA-Z0-9.-]{2,249}\.[a-zA-Z]{2,20}$/', message: 'email-error')]
- #[Groups(['contactpoint', 'access_details_person', 'access_details_guardians', 'student_list_person', 'guardians_list_person', 'all_accesses_list_person', 'teachers_list_person', 'adherent_list_person', 'personnels_list_person', 'morals_list_person', 'ca_list_person', 'accesses_list_person', 'othercontact_list_person', 'place_list_contactpoint', 'report_card_person', 'report_card_guardians', 'student_registration_person', 'student_registration_guardians', 'board_list_person', 'network_list_contactpoint', 'federations_list_contactpoint', 'networkmanagers_list_person', 'network_artist_school_list_contactpoint', 'network_list_adminaccess', 'adherent_contact_person', 'adherent_contact_guardians', 'access_mail_person', 'student_list_guardians', 'access_mail_guardians', 'organization_details_contactpoint', 'payer_list_person', 'access_duplicate_control_list_person', 'organization_cotisation_steps_contactpoint', 'template', 'view_from_manager_create_person', 'online_registration_access_details_person', 'onlineregistration_infos_organization', 'accesses_no_reregistred_list_person', 'accesses_no_reregistred_list_guardians', 'cmf_network_organizations_contactpoint'])]
- private $email;
- /**
- * @var string Invalid Email address.
- *
- * @Iri("https://schema.org/email")
- */
- #[ORM\Column(type: 'string', length: 255, nullable: true)]
- #[Groups(['contactpoint'])]
- private $emailInvalid;
- /**
- * @var string The fax number.
- *
- * @AssertPhoneNumber
- * @Iri("https://schema.org/faxNumber")
- */
- #[ORM\Column(type: 'phone_number', nullable: true)]
- #[Groups(['contactpoint', 'access_details_person', 'access_duplicate_control_list_person', 'organization_cotisation_steps_contactpoint', 'organization_details_contactpoint'])]
- private $faxNumber;
- /**
- * @var string The invalid fax number.
- *
- * @Iri("https://schema.org/faxNumber")
- */
- #[ORM\Column(type: 'string', length: 255, nullable: true)]
- #[Groups(['contactpoint'])]
- private $faxNumberInvalid;
- /**
- * @var string
- *
- * @AssertPhoneNumber
- * @Confidentiality(visibility=\AppBundle\Enum\Confidentiality\ConfidentialityTypeEnum::VISIBILITY_ORGANIZATION)
- */
- #[ORM\Column(type: 'phone_number', nullable: true)]
- #[Groups(['contactpoint', 'access_details_person', 'access_details_guardians', 'student_list_person', 'guardians_list_person', 'teachers_list_person', 'adherent_list_person', 'personnels_list_person', 'morals_list_person', 'ca_list_person', 'accesses_list_person', 'othercontact_list_person', 'place_list_contactpoint', 'student_registration_person', 'student_registration_guardians', 'board_list_person', 'all_accesses_list_person', 'network_list_contactpoint', 'federations_list_contactpoint', 'networkmanagers_list_person', 'network_artist_school_list_contactpoint', 'adherent_contact_person', 'adherent_contact_guardians', 'student_list_guardians', 'organization_details_contactpoint', 'payer_list_person', 'access_duplicate_control_list_person', 'organization_cotisation_steps_contactpoint', 'view_from_manager_create_person', 'online_registration_access_details_person', 'onlineregistration_infos_organization', 'accesses_no_reregistred_list_person', 'accesses_no_reregistred_list_guardians', 'cmf_network_organizations_contactpoint'])]
- private $telphone;
- /**
- * @var string
- */
- #[ORM\Column(type: 'string', length: 255, nullable: true)]
- #[Groups(['contactpoint'])]
- private $telphoneInvalid;
- /**
- * @var string
- *
- * @AssertPhoneNumber
- * @Confidentiality(visibility=\AppBundle\Enum\Confidentiality\ConfidentialityTypeEnum::VISIBILITY_ORGANIZATION)
- */
- #[ORM\Column(type: 'phone_number', nullable: true)]
- #[Groups(['contactpoint', 'access_details_person', 'access_details_guardians', 'student_registration_person', 'student_registration_guardians', 'student_list_person', 'accesses_list_person', 'guardians_list_person', 'teachers_list_person', 'adherent_list_person', 'personnels_list_person', 'morals_list_person', 'ca_list_person', 'all_accesses_list_person', 'othercontact_list_person', 'board_list_person', 'student_list_guardians', 'network_list_contactpoint', 'federations_list_contactpoint', 'networkmanagers_list_person', 'organization_details_contactpoint', 'payer_list_person', 'adherent_contact_person', 'access_duplicate_control_list_person', 'organization_cotisation_steps_contactpoint', 'view_from_manager_create_person', 'online_registration_access_details_person', 'onlineregistration_infos_organization', 'accesses_no_reregistred_list_person', 'accesses_no_reregistred_list_guardians', 'cmf_network_organizations_contactpoint'])]
- private $mobilPhone;
- /**
- * @var string
- */
- #[ORM\Column(type: 'string', length: 255, nullable: true)]
- #[Groups(['contactpoint'])]
- private $mobilPhoneInvalid;
- /**
- * @var string
- * @ExportSplitFields({"email","telphoneTemplate","mobilPhoneTemplate"})
- */
- #[Groups(['template', 'place_list_contactpoint'])]
- private $fullLabelTemplate;
- /**
- * @var string
- */
- #[Groups(['template'])]
- private $telphoneTemplate;
- /**
- * @var string
- */
- #[Groups(['template'])]
- private $mobilPhoneTemplate;
- /**
- * @var Organization
- */
- #[ORM\ManyToMany(targetEntity: 'AppBundle\Entity\Organization\Organization', mappedBy: 'contactPoint')]
- private $organization;
- /**
- * @var Person
- */
- #[ORM\ManyToMany(targetEntity: 'AppBundle\Entity\Person\Person', mappedBy: 'contactPoint')]
- private $person;
- /**
- * @var Place
- */
- #[ORM\ManyToMany(targetEntity: 'AppBundle\Entity\Place\Place', mappedBy: 'contactpoint')]
- private $place;
- /**
- *
- * @var string
- */
- #[ORM\Column(type: 'text', nullable: true)]
- #[Assert\Type(type: 'string')]
- #[Groups(['contactpoint'])]
- private $invalidReason;
- /**
- *
- * @var string
- */
- #[ORM\Column(type: 'text', nullable: true)]
- #[Assert\Type(type: 'string')]
- private $invalidEmailBody;
- /**
- *
- * @var string
- */
- #[ORM\Column(type: 'string', length: 255, nullable: true)]
- #[Assert\Type(type: 'string')]
- private $invalidCat;
- /**
- *
- * @var string
- */
- #[ORM\Column(type: 'string', length: 255, nullable: true)]
- #[Assert\Type(type: 'string')]
- private $invalidStatus;
- /**
- * @var string
- * @ExportFilter({"contactType","PRINCIPAL"})
- * @ExportSplitFields({"email","telphoneTemplate","mobilPhoneTemplate"})
- */
- #[Groups(['template'])]
- private $fullLabelPrincipalTemplate;
- /**
- * @var string
- * @ExportFilter({"contactType","CONTACT"})
- * @ExportSplitFields({"email","telphoneTemplate","mobilPhoneTemplate"})
- */
- #[Groups(['template'])]
- private $fullLabelContactTemplate;
- /**
- * @var string
- * @ExportFilter({"contactType","BILL"})
- * @ExportSplitFields({"email","telphoneTemplate","mobilPhoneTemplate"})
- */
- #[Groups(['template'])]
- private $fullLabelBillTemplate;
- /**
- * Constructor
- */
- public function __construct()
- {
- $this->organization = new \Doctrine\Common\Collections\ArrayCollection();
- $this->person = new \Doctrine\Common\Collections\ArrayCollection();
- $this->place = new \Doctrine\Common\Collections\ArrayCollection();
- }
- /**
- * Sets id.
- *
- * @param int $id
- *
- * @return $this
- */
- public function setId($id)
- {
- $this->id = $id;
- return $this;
- }
- /**
- * Gets id.
- *
- * @return int
- */
- public function getId()
- {
- return $this->id;
- }
- /**
- * Get organization
- *
- * @return \Doctrine\Common\Collections\Collection
- */
- public function getOrganization()
- {
- return $this->organization;
- }
- /**
- * Get person
- *
- * @return \Doctrine\Common\Collections\Collection
- */
- public function getPerson()
- {
- return $this->person;
- }
- /**
- * Get place
- *
- * @return \Doctrine\Common\Collections\Collection
- */
- public function getPlace()
- {
- return $this->place;
- }
- /**
- * Sets contactType.
- *
- * @param string $contactType
- *
- * @return $this
- */
- public function setContactType($contactType)
- {
- $this->contactType = $contactType;
- return $this;
- }
- /**
- * Gets contactType.
- *
- * @return string
- */
- public function getContactType()
- {
- return $this->contactType;
- }
- /**
- * Sets email.
- *
- * @param string $email
- *
- * @return $this
- */
- public function setEmail($email)
- {
- $this->email = $email;
- if(!is_null($email) && !is_null($this->getEmailInvalid()))
- $this->setEmailInvalid(NULL);
- return $this;
- }
- /**
- * Gets email.
- *
- * @return string
- */
- public function getEmail()
- {
- return $this->email;
- }
- /**
- * Sets email Invalid.
- *
- * @param string $emailInvalid
- *
- * @return $this
- */
- public function setEmailInvalid($emailInvalid)
- {
- $this->emailInvalid = is_null($this->email) ? $emailInvalid : NULL;
- return $this;
- }
- /**
- * Gets email Invalid.
- *
- * @return string
- */
- public function getEmailInvalid()
- {
- return $this->emailInvalid;
- }
- /**
- * Sets faxNumber.
- *
- * @param string $faxNumber
- *
- * @return $this
- */
- public function setFaxNumber($faxNumber)
- {
- if(empty($faxNumber))$faxNumber = null;
- if(is_null($faxNumber)) $this->faxNumber = $faxNumber;
- else{
- $phoneUtil = PhoneNumberUtil::getInstance();
- $phoneNumber = $phoneUtil->parse($faxNumber, PhoneNumberUtil::UNKNOWN_REGION);
- $this->faxNumber = $phoneNumber;
- }
- if(!is_null($this->faxNumber) && !is_null($this->getFaxNumberInvalid()))
- $this->setFaxNumberInvalid(NULL);
- return $this;
- }
- /**
- * Gets faxNumber.
- *
- * @return string
- */
- public function getFaxNumber()
- {
- return $this->faxNumber;
- }
- /**
- * Sets faxNumber Invalid.
- *
- * @param string $faxNumberInvalid
- *
- * @return $this
- */
- public function setFaxNumberInvalid($faxNumberInvalid)
- {
- $this->faxNumberInvalid = is_null($this->faxNumber) ? $faxNumberInvalid : NULL;
- return $this;
- }
- /**
- * Gets faxNumber Invalid.
- *
- * @return string
- */
- public function getFaxNumberInvalid()
- {
- return $this->faxNumberInvalid;
- }
- /**
- * Sets telphone.
- *
- * @param string $telphone
- *
- * @return $this
- */
- public function setTelphone($telphone)
- {
- if(empty($telphone))$telphone = null;
- if(is_null($telphone)) $this->telphone = $telphone;
- else{
- $phoneUtil = PhoneNumberUtil::getInstance();
- $phoneNumber = $phoneUtil->parse($telphone, PhoneNumberUtil::UNKNOWN_REGION);
- $this->telphone = $phoneNumber;
- }
- if(!is_null($this->telphone) && !is_null($this->getTelphoneInvalid()))
- $this->setTelphoneInvalid(NULL);
- return $this;
- }
- public function setPhoneNumberTelphone(PhoneNumber $phoneNumberTelphone)
- {
- $this->telphone = $phoneNumberTelphone;
- }
- /**
- * Gets telphone.
- *
- * @return string
- */
- public function getTelphone()
- {
- return $this->telphone;
- }
- /**
- * Sets telphone Invalid.
- *
- * @param string $telphoneInvalid
- *
- * @return $this
- */
- public function setTelphoneInvalid($telphoneInvalid)
- {
- $this->telphoneInvalid = is_null($this->telphone) ? $telphoneInvalid : NULL;
- return $this;
- }
- /**
- * Gets telphone Invalid.
- *
- * @return string
- */
- public function getTelphoneInvalid()
- {
- return $this->telphoneInvalid;
- }
- /**
- * Sets mobilPhone.
- *
- * @param string $mobilPhone
- *
- * @return $this
- */
- public function setMobilPhone($mobilPhone)
- {
- if(empty($mobilPhone))$mobilPhone = null;
- if(is_null($mobilPhone)) $this->mobilPhone = $mobilPhone;
- else{
- $phoneUtil = PhoneNumberUtil::getInstance();
- $phoneNumber = $phoneUtil->parse($mobilPhone, PhoneNumberUtil::UNKNOWN_REGION);
- $this->mobilPhone = $phoneNumber;
- }
- if(!is_null($this->mobilPhone) && !is_null($this->getMobilPhoneInvalid()))
- $this->setMobilPhoneInvalid(NULL);
- return $this;
- }
- public function setPhoneNumberMobilPhone(PhoneNumber $phoneNumberMobilPhone){
- $this->mobilPhone = $phoneNumberMobilPhone;
- }
- /**
- * Gets mobilPhone.
- *
- * @return string
- */
- public function getMobilPhone()
- {
- return $this->mobilPhone;
- }
- /**
- * Sets mobilPhone Invalid .
- *
- * @param string $mobilPhoneInvalid
- *
- * @return $this
- */
- public function setMobilPhoneInvalid($mobilPhoneInvalid)
- {
- $this->mobilPhoneInvalid = is_null($this->mobilPhone) ? $mobilPhoneInvalid : NULL;
- return $this;
- }
- /**
- * Gets mobilPhone Invalid.
- *
- * @return string
- */
- public function getMobilPhoneInvalid()
- {
- return $this->mobilPhoneInvalid;
- }
- /**
- * Gets full label.
- *
- * @return array
- */
- public function getFullLabelTemplate()
- {
- return [
- $this->getEmail(),
- $this->getTelphoneTemplate()[0],
- $this->getMobilPhoneTemplate()[0]
- ];
- }
- /**
- * Gets full label.
- *
- * @return array
- */
- public function getTelphoneTemplate()
- {
- return [
- ['type' => 'phone_number', 'value' => $this->getTelphone(), 'separator' => ' / ']
- ];
- }
- /**
- * Gets full label.
- *
- * @return array
- */
- public function getMobilPhoneTemplate()
- {
- return [
- ['type' => 'phone_number', 'value' => $this->getMobilPhone(), 'separator' => ' / ']
- ];
- }
- /**
- * Add organization
- *
- * @param \AppBundle\Entity\Organization\Organization $organization
- *
- * @return ContactPoint
- */
- public function addOrganization(\AppBundle\Entity\Organization\Organization $organization)
- {
- $this->organization[] = $organization;
- return $this;
- }
- /**
- * Remove organization
- *
- * @param \AppBundle\Entity\Organization\Organization $organization
- */
- public function removeOrganization(\AppBundle\Entity\Organization\Organization $organization)
- {
- $this->organization->removeElement($organization);
- }
- /**
- * Add person
- *
- * @param \AppBundle\Entity\Person\Person $person
- *
- * @return ContactPoint
- */
- public function addPerson(\AppBundle\Entity\Person\Person $person)
- {
- $this->person[] = $person;
- return $this;
- }
- /**
- * Remove person
- *
- * @param \AppBundle\Entity\Person\Person $person
- */
- public function removePerson(\AppBundle\Entity\Person\Person $person)
- {
- $person->removeContactPoint($this);
- $this->person->removeElement($person);
- }
- /**
- * Add place
- *
- * @param \AppBundle\Entity\Place\Place $place
- *
- * @return ContactPoint
- */
- public function addPlace(\AppBundle\Entity\Place\Place $place)
- {
- $this->place[] = $place;
- return $this;
- }
- /**
- * Remove place
- *
- * @param \AppBundle\Entity\Place\Place $place
- */
- public function removePlace(\AppBundle\Entity\Place\Place $place)
- {
- $this->place->removeElement($place);
- }
- /**
- * Gets invalidReason.
- *
- * @return string
- */
- public function getInvalidReason()
- {
- return $this->invalidReason;
- }
- /**
- * Sets invalidReason
- *
- * @param string $invalidReason
- *
- * @return $this
- */
- public function setInvalidReason($invalidReason)
- {
- $this->invalidReason = $invalidReason;
- return $this;
- }
- /**
- * @return string
- */
- public function getInvalidStatus()
- {
- return $this->invalidStatus;
- }
- /**
- * @param string $invalidStatus
- */
- public function setInvalidStatus($invalidStatus)
- {
- $this->invalidStatus = $invalidStatus;
- }
- /**
- * Gets full label.
- *
- * @return array
- */
- public function getFullLabelPrincipalTemplate()
- {
- return $this->getFullLabelTemplateByType(ContactPointTypeEnum::PRINCIPAL);
- }
- /**
- * Gets full label.
- *
- * @return array
- */
- public function getFullLabelContactTemplate()
- {
- return $this->getFullLabelTemplateByType(ContactPointTypeEnum::CONTACT);
- }
- /**
- * Gets full label.
- *
- * @return string
- */
- public function getFullLabelBillTemplate()
- {
- return $this->getFullLabelTemplateByType(ContactPointTypeEnum::BILL);
- }
- /**
- * @param $contactPointTypeEnum
- * @return array
- */
- private function getFullLabelTemplateByType($contactPointTypeEnum)
- {
- $label = [];
- if($this->contactType === $contactPointTypeEnum){
- $label = [
- $this->getEmail(),
- ['type' => 'phone_number', 'value' => $this->getTelphone()],
- ['type' => 'phone_number', 'value' => $this->getMobilPhone()]
- ];
- }
- return $label;
- }
- /**
- * @return string
- */
- public function getInvalidEmailBody()
- {
- return $this->invalidEmailBody;
- }
- /**
- * @param string $invalidEmailBody
- */
- public function setInvalidEmailBody($invalidEmailBody)
- {
- $this->invalidEmailBody = $invalidEmailBody;
- }
- /**
- * @return string
- */
- public function getInvalidCat()
- {
- return $this->invalidCat;
- }
- /**
- * @param string $invalidCat
- */
- public function setInvalidCat($invalidCat)
- {
- $this->invalidCat = $invalidCat;
- }
- }
|