| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280 |
- <?php
- declare(strict_types=1);
- namespace App\Entity\Core;
- use ApiPlatform\Metadata\ApiResource;
- use App\Entity\Organization\OrganizationAddressPostal;
- use App\Entity\Person\PersonAddressPostal;
- use App\Entity\Place\AbstractPlace;
- // use DH\Auditor\Provider\Doctrine\Auditing\Annotation\Auditable;
- use App\Repository\Core\AddressPostalRepository;
- use Doctrine\Common\Collections\ArrayCollection;
- use Doctrine\Common\Collections\Collection;
- use Doctrine\ORM\Mapping as ORM;
- use Symfony\Component\Serializer\Annotation\Groups;
- /**
- * Adresse postale d'une organisation ou d'une personne.
- *
- * Security :
- *
- * * @see App\Doctrine\Core\AllowedAddressPostalExtension
- */
- #[ApiResource(operations: [])]
- // #[Auditable]
- #[ORM\Entity(repositoryClass: AddressPostalRepository::class)]
- class AddressPostal
- {
- #[ORM\Id]
- #[ORM\Column]
- #[ORM\GeneratedValue]
- #[Groups(['address', 'access_address'])]
- private ?int $id = null;
- #[ORM\ManyToOne]
- #[Groups('address')]
- private ?Country $addressCountry = null;
- #[ORM\Column(length: 100, nullable: true)]
- #[Groups('address')]
- private ?string $addressCity = null;
- #[ORM\Column(length: 100, nullable: true)]
- #[Groups('address')]
- private ?string $addressOwner = null;
- #[ORM\Column(length: 20, nullable: true)]
- #[Groups('address')]
- private ?string $postalCode = null;
- #[ORM\Column(length: 255, nullable: true)]
- #[Groups('address')]
- private ?string $streetAddress = null;
- #[ORM\Column(length: 255, nullable: true)]
- #[Groups('address')]
- private ?string $streetAddressSecond = null;
- #[ORM\Column(length: 255, nullable: true)]
- #[Groups('address')]
- private ?string $streetAddressThird = null;
- #[ORM\Column(nullable: true)]
- #[Groups('address')]
- private ?float $latitude = null;
- #[ORM\Column(nullable: true)]
- #[Groups('address')]
- private ?float $longitude = null;
- #[ORM\OneToOne(mappedBy: 'addressPostal')]
- private OrganizationAddressPostal $organizationAddressPostal;
- #[ORM\OneToOne(mappedBy: 'addressPostal')]
- private PersonAddressPostal $personAddressPostal;
- #[ORM\OneToMany(mappedBy: 'addressPostal', targetEntity: AbstractPlace::class)]
- private Collection $places;
- #[ORM\OneToMany(mappedBy: 'addressPostal', targetEntity: OrganizationAddressPostal::class, cascade: [], orphanRemoval: false)]
- protected Collection $organizationAddressPostals;
- public function __construct()
- {
- $this->places = new ArrayCollection();
- $this->organizationAddressPostals = new ArrayCollection();
- }
- public function getId(): ?int
- {
- return $this->id;
- }
- public function getAddressCountry(): ?Country
- {
- return $this->addressCountry;
- }
- public function setAddressCountry(?Country $addressCountry): self
- {
- $this->addressCountry = $addressCountry;
- return $this;
- }
- public function getAddressCity(): ?string
- {
- return $this->addressCity;
- }
- public function setAddressCity(?string $addressCity): self
- {
- $this->addressCity = $addressCity;
- return $this;
- }
- public function getAddressOwner(): ?string
- {
- return $this->addressOwner;
- }
- public function setAddressOwner(?string $addressOwner): self
- {
- $this->addressOwner = $addressOwner;
- return $this;
- }
- public function getPostalCode(): ?string
- {
- return $this->postalCode;
- }
- public function setPostalCode(?string $postalCode): self
- {
- $this->postalCode = $postalCode;
- return $this;
- }
- public function getStreetAddress(): ?string
- {
- return $this->streetAddress;
- }
- public function setStreetAddress(?string $streetAddress): self
- {
- $this->streetAddress = $streetAddress;
- return $this;
- }
- public function getStreetAddressSecond(): ?string
- {
- return $this->streetAddressSecond;
- }
- public function setStreetAddressSecond(?string $streetAddressSecond): self
- {
- $this->streetAddressSecond = $streetAddressSecond;
- return $this;
- }
- public function getStreetAddressThird(): ?string
- {
- return $this->streetAddressThird;
- }
- public function setStreetAddressThird(?string $streetAddressThird): self
- {
- $this->streetAddressThird = $streetAddressThird;
- return $this;
- }
- public function getLatitude(): ?float
- {
- return $this->latitude;
- }
- public function setLatitude(?float $latitude): self
- {
- $this->latitude = $latitude;
- return $this;
- }
- public function getLongitude(): ?float
- {
- return $this->longitude;
- }
- public function setLongitude(?float $longitude): self
- {
- $this->longitude = $longitude;
- return $this;
- }
- public function getOrganizationAddressPostal(): ?OrganizationAddressPostal
- {
- return $this->organizationAddressPostal;
- }
- public function setOrganizationAddressPostal(OrganizationAddressPostal $organizationAddressPostal): self
- {
- $this->organizationAddressPostal = $organizationAddressPostal;
- return $this;
- }
- public function getPersonAddressPostal(): ?PersonAddressPostal
- {
- return $this->personAddressPostal;
- }
- public function setPersonAddressPostal(PersonAddressPostal $personAddressPostal): self
- {
- $this->personAddressPostal = $personAddressPostal;
- return $this;
- }
- /**
- * @return Collection<int, AbstractPlace>
- */
- public function getPlaces(): Collection
- {
- return $this->places;
- }
- public function addPlace(AbstractPlace $place): self
- {
- if (!$this->places->contains($place)) {
- $this->places[] = $place;
- $place->setAddressPostal($this);
- }
- return $this;
- }
- public function removePlace(AbstractPlace $place): self
- {
- if ($this->places->removeElement($place)) {
- // set the owning side to null (unless already changed)
- if ($place->getAddressPostal() === $this) {
- $place->setAddressPostal(null);
- }
- }
- return $this;
- }
- function getOrganizationAddressPostals(): Collection
- {
- return $this->organizationAddressPostals;
- }
- function addOrganizationAddressPostal(OrganizationAddressPostal $organizationAddressPostal): self
- {
- if (!$this->organizationAddressPostals->contains($organizationAddressPostal)) {
- $this->organizationAddressPostals[] = $organizationAddressPostal;
- $organizationAddressPostal->setAddressPostal($this);
- }
- return $this;
- }
- function removeOrganizationAddressPostal(OrganizationAddressPostal $organizationAddressPostal): self
- {
- if ($this->organizationAddressPostals->removeElement($organizationAddressPostal)) {
- // $organizationAddressPostal->setAddressPostal(null); // TODO: actuellement, pas nullable: conserver?
- }
- return $this;
- }
- }
|