| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199 |
- <?php
- namespace AppBundle\Entity\Person;
- use AppBundle\Annotation\ExportSplitFields;
- use AppBundle\Entity\Core\AddressPostal;
- use AppBundle\Enum\Core\AddressPostalTypeEnum;
- use Doctrine\ORM\Mapping as ORM;
- use Dunglas\ApiBundle\Annotation\Iri;
- use Symfony\Component\Serializer\Annotation\Groups;
- use Symfony\Component\Validator\Constraints as Assert;
- use AppBundle\Entity\Traits\TimestampableEntity;
- use AppBundle\Entity\Traits\CreatorUpdaterEntity;
- /**
- * Lien entre une Person et une AdressPostal, associé à un type
- *
- * @Iri("http://schema.org/PersonAddressPostal")
- */
- #[ORM\Entity]
- #[Assert\Callback(['AppBundle\Validator\Constraints\Core\PersonAddressPostalValidator', 'validate'])]
- class PersonAddressPostal
- {
- use TimestampableEntity;
- use CreatorUpdaterEntity;
- /**
- * @var int
- */
- #[ORM\Column(type: 'integer')]
- #[ORM\Id]
- #[ORM\GeneratedValue(strategy: 'AUTO')]
- #[Groups(['personaddresspostal', 'access_details_guardians', 'student_registration_person', 'student_registration_guardians', 'accesses_list_person', 'student_list_person', 'guardians_list_person', 'teachers_list_person', 'adherent_list_person', 'personnels_list_person', 'morals_list_person', 'ca_list_person', 'othercontact_list_person', 'board_list_person', 'networkmanagers_list_person', 'sepa_debit_mandate_person', 'equipment_availability_form_borrower', 'online_registration_access_details_person'])]
- private $id;
- /**
- * @var Person
- */
- #[ORM\ManyToOne(targetEntity: 'AppBundle\Entity\Person\Person', inversedBy: 'personAddressPostal')]
- #[ORM\JoinColumn(nullable: false)]
- #[Assert\NotNull]
- #[Groups(['personaddresspostal'])]
- private $person;
- /**
- * @var AddressPostal
- */
- #[Assert\Valid]
- #[ORM\ManyToOne(targetEntity: 'AppBundle\Entity\Core\AddressPostal', cascade: ['persist'], inversedBy: 'personAddressPostal', fetch: 'EAGER')]
- #[ORM\JoinColumn(nullable: false)]
- #[Assert\NotNull]
- #[Groups(['personaddresspostal', 'access_details_person', 'morals_list_person', 'report_card_person', 'report_card_guardians', 'access_details_guardians', 'student_registration_person', 'student_registration_guardians', 'accesses_list_person', 'student_list_person', 'education_student_next_year_access', 'guardians_list_person', 'all_accesses_list_person', 'teachers_list_person', 'adherent_list_person', 'personnels_list_person', 'ca_list_person', 'othercontact_list_person', 'access_duplicate_control_list_person', 'board_list_person', 'networkmanagers_list_person', 'payer_list_person', 'sepa_debit_mandate_person', 'student_list_guardians', 'equipment_availability_form_borrower', 'view_from_manager_create_person', 'online_registration_access_details_person', 'build_bills_access'])]
- private $addressPostal;
- /**
- * @var string
- */
- #[ORM\Column(type: 'string')]
- #[Assert\Type(type: 'string')]
- #[Assert\NotNull]
- #[Assert\Choice(callback: ['AppBundle\Enum\Core\AddressPostalTypeEnum', 'toArray'])]
- #[Groups(['personaddresspostal', 'access_details_person', 'report_card_person', 'report_card_guardians', 'student_registration_person', 'student_registration_guardians', 'accesses_list_person', 'student_list_person', 'education_student_next_year_access', 'guardians_list_person', 'teachers_list_person', 'adherent_list_person', 'personnels_list_person', 'morals_list_person', 'ca_list_person', 'othercontact_list_person', 'access_duplicate_control_list_person', 'board_list_person', 'networkmanagers_list_person', 'payer_list_person', 'sepa_debit_mandate_person', 'equipment_availability_form_borrower', 'view_from_manager_create_person', 'online_registration_access_details_person', 'build_bills_access'])]
- private $type;
- /**
- * @var string
- * @ExportSplitFields({"addressPostal.streetAddress","addressPostal.streetAddressSecond","addressPostal.streetAddressThird","addressPostal.postalCode","addressPostal.addressCity"})
- */
- #[Groups(['template'])]
- private $fullLabelTemplate;
- /**
- * @var string
- */
- #[Groups(['template'])]
- private $fullLabelExportPrincipalTemplate;
- /**
- * @var string
- */
- #[Groups(['template'])]
- private $fullLabelExportPrincipalStreetTemplate;
- /**
- * 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;
- }
- /**
- * Sets person.
- *
- * @param Person $person
- *
- * @return $this
- */
- public function setPerson(Person $person)
- {
- $this->person = $person;
- return $this;
- }
- /**
- * Gets person.
- *
- * @return Person
- */
- public function getPerson()
- {
- return $this->person;
- }
- /**
- * Sets address postal.
- *
- * @param AddressPostal $addressPostal
- *
- * @return $this
- */
- public function setAddressPostal(AddressPostal $addressPostal)
- {
- $addressPostal->addPersonAddressPostal($this);
- $this->addressPostal = $addressPostal;
- return $this;
- }
- /**
- * Gets address postal.
- *
- * @return AddressPostal
- */
- public function getAddressPostal()
- {
- return $this->addressPostal;
- }
- /**
- * Sets type.
- *
- * @param string $type
- *
- * @return $this
- */
- public function setType($type)
- {
- $this->type = $type;
- return $this;
- }
- /**
- * Gets type.
- *
- * @return string
- */
- public function getType()
- {
- return $this->type;
- }
- /**
- * Gets full label.
- *
- * @return array
- */
- public function getFullLabelTemplate()
- {
- return [
- $this->getAddressPostal()->getStreetAddress(),
- $this->getAddressPostal()->getStreetAddressSecond(),
- $this->getAddressPostal()->getStreetAddressThird(),
- $this->getAddressPostal()->getPostalCode(),
- $this->getAddressPostal()->getAddressCity()
- ];
- }
- public function getFullLabelExportPrincipalTemplate(){
- $addressLabel = [];
- if($this->type === AddressPostalTypeEnum::ADDRESS_PRINCIPAL){
- $addressLabel = $this->getFullLabelTemplate();
- }
- return $addressLabel;
- }
- public function getFullLabelExportPrincipalStreetTemplate(){
- $addressLabel = [];
- $addressLabel[] = ['value' => $this->getAddressPostal()->getStreetAddress(), 'separator' => ' / '];
- $addressLabel[] = ['value' => $this->getAddressPostal()->getStreetAddressSecond(), 'separator' => ' / '];
- $addressLabel[] = ['value' => $this->getAddressPostal()->getStreetAddressThird(), 'separator' => ' / '];
- return $addressLabel;
- }
- }
|