AddressPostal.php 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Entity\Core;
  4. use ApiPlatform\Metadata\ApiResource;
  5. use App\Entity\Organization\OrganizationAddressPostal;
  6. use App\Entity\Person\PersonAddressPostal;
  7. // use DH\Auditor\Provider\Doctrine\Auditing\Annotation\Auditable;
  8. use App\Entity\Place\Place;
  9. use App\Entity\Traits\CreatedOnAndByTrait;
  10. use App\Repository\Core\AddressPostalRepository;
  11. use Doctrine\Common\Collections\ArrayCollection;
  12. use Doctrine\Common\Collections\Collection;
  13. use Doctrine\ORM\Mapping as ORM;
  14. use Symfony\Component\Serializer\Annotation\Groups;
  15. /**
  16. * Adresse postale d'une organisation ou d'une personne.
  17. *
  18. * Security :
  19. *
  20. * * @see App\Doctrine\Core\AllowedAddressPostalExtension
  21. */
  22. #[ApiResource(operations: [])]
  23. // #[Auditable]
  24. #[ORM\Entity(repositoryClass: AddressPostalRepository::class)]
  25. class AddressPostal
  26. {
  27. use CreatedOnAndByTrait;
  28. #[ORM\Id]
  29. #[ORM\Column]
  30. #[ORM\GeneratedValue]
  31. #[Groups(['address', 'access_address'])]
  32. private ?int $id = null;
  33. #[ORM\ManyToOne]
  34. #[Groups('address')]
  35. private ?Country $addressCountry = null;
  36. #[ORM\Column(length: 100, nullable: true)]
  37. #[Groups('address')]
  38. private ?string $addressCity = null;
  39. #[ORM\Column(length: 100, nullable: true)]
  40. #[Groups('address')]
  41. private ?string $addressOwner = null;
  42. #[ORM\Column(length: 10, nullable: true)]
  43. #[Groups('address')]
  44. private ?string $postalCode = null;
  45. #[ORM\Column(length: 255, nullable: true)]
  46. #[Groups('address')]
  47. private ?string $streetAddress = null;
  48. #[ORM\Column(length: 255, nullable: true)]
  49. #[Groups('address')]
  50. private ?string $streetAddressSecond = null;
  51. #[ORM\Column(length: 255, nullable: true)]
  52. #[Groups('address')]
  53. private ?string $streetAddressThird = null;
  54. #[ORM\Column(nullable: true)]
  55. #[Groups('address')]
  56. private ?float $latitude = null;
  57. #[ORM\Column(nullable: true)]
  58. #[Groups('address')]
  59. private ?float $longitude = null;
  60. #[ORM\OneToOne(mappedBy: 'addressPostal')]
  61. private ?OrganizationAddressPostal $organizationAddressPostal = null;
  62. #[ORM\OneToOne(mappedBy: 'addressPostal')]
  63. private ?PersonAddressPostal $personAddressPostal = null;
  64. /** @var Collection<int, Place> */
  65. #[ORM\OneToMany(mappedBy: 'addressPostal', targetEntity: Place::class)]
  66. private Collection $places;
  67. /** @var Collection<int, OrganizationAddressPostal> */
  68. #[ORM\OneToMany(mappedBy: 'addressPostal', targetEntity: OrganizationAddressPostal::class, cascade: [], orphanRemoval: false)]
  69. protected Collection $organizationAddressPostals;
  70. public function __construct()
  71. {
  72. $this->places = new ArrayCollection();
  73. $this->organizationAddressPostals = new ArrayCollection();
  74. }
  75. public function getId(): ?int
  76. {
  77. return $this->id;
  78. }
  79. public function getAddressCountry(): ?Country
  80. {
  81. return $this->addressCountry;
  82. }
  83. public function setAddressCountry(?Country $addressCountry): self
  84. {
  85. $this->addressCountry = $addressCountry;
  86. return $this;
  87. }
  88. public function getAddressCity(): ?string
  89. {
  90. return $this->addressCity;
  91. }
  92. public function setAddressCity(?string $addressCity): self
  93. {
  94. $this->addressCity = $addressCity;
  95. return $this;
  96. }
  97. public function getAddressOwner(): ?string
  98. {
  99. return $this->addressOwner;
  100. }
  101. public function setAddressOwner(?string $addressOwner): self
  102. {
  103. $this->addressOwner = $addressOwner;
  104. return $this;
  105. }
  106. public function getPostalCode(): ?string
  107. {
  108. return $this->postalCode;
  109. }
  110. public function setPostalCode(?string $postalCode): self
  111. {
  112. $this->postalCode = $postalCode;
  113. return $this;
  114. }
  115. public function getStreetAddress(): ?string
  116. {
  117. return $this->streetAddress;
  118. }
  119. public function setStreetAddress(?string $streetAddress): self
  120. {
  121. $this->streetAddress = $streetAddress;
  122. return $this;
  123. }
  124. public function getStreetAddressSecond(): ?string
  125. {
  126. return $this->streetAddressSecond;
  127. }
  128. public function setStreetAddressSecond(?string $streetAddressSecond): self
  129. {
  130. $this->streetAddressSecond = $streetAddressSecond;
  131. return $this;
  132. }
  133. public function getStreetAddressThird(): ?string
  134. {
  135. return $this->streetAddressThird;
  136. }
  137. public function setStreetAddressThird(?string $streetAddressThird): self
  138. {
  139. $this->streetAddressThird = $streetAddressThird;
  140. return $this;
  141. }
  142. public function getLatitude(): ?float
  143. {
  144. return $this->latitude;
  145. }
  146. public function setLatitude(?float $latitude): self
  147. {
  148. $this->latitude = $latitude;
  149. return $this;
  150. }
  151. public function getLongitude(): ?float
  152. {
  153. return $this->longitude;
  154. }
  155. public function setLongitude(?float $longitude): self
  156. {
  157. $this->longitude = $longitude;
  158. return $this;
  159. }
  160. public function getOrganizationAddressPostal(): ?OrganizationAddressPostal
  161. {
  162. return $this->organizationAddressPostal;
  163. }
  164. public function setOrganizationAddressPostal(OrganizationAddressPostal $organizationAddressPostal): self
  165. {
  166. $this->organizationAddressPostal = $organizationAddressPostal;
  167. return $this;
  168. }
  169. public function getPersonAddressPostal(): ?PersonAddressPostal
  170. {
  171. return $this->personAddressPostal;
  172. }
  173. public function setPersonAddressPostal(PersonAddressPostal $personAddressPostal): self
  174. {
  175. $this->personAddressPostal = $personAddressPostal;
  176. return $this;
  177. }
  178. /**
  179. * @return Collection<int, Place>
  180. */
  181. public function getPlaces(): Collection
  182. {
  183. return $this->places;
  184. }
  185. public function addPlace(Place $place): self
  186. {
  187. if (!$this->places->contains($place)) {
  188. $this->places[] = $place;
  189. $place->setAddressPostal($this);
  190. }
  191. return $this;
  192. }
  193. public function removePlace(Place $place): self
  194. {
  195. if ($this->places->removeElement($place)) {
  196. // set the owning side to null (unless already changed)
  197. if ($place->getAddressPostal() === $this) {
  198. $place->setAddressPostal(null);
  199. }
  200. }
  201. return $this;
  202. }
  203. public function getOrganizationAddressPostals(): Collection
  204. {
  205. return $this->organizationAddressPostals;
  206. }
  207. public function addOrganizationAddressPostal(OrganizationAddressPostal $organizationAddressPostal): self
  208. {
  209. if (!$this->organizationAddressPostals->contains($organizationAddressPostal)) {
  210. $this->organizationAddressPostals[] = $organizationAddressPostal;
  211. $organizationAddressPostal->setAddressPostal($this);
  212. }
  213. return $this;
  214. }
  215. public function removeOrganizationAddressPostal(OrganizationAddressPostal $organizationAddressPostal): self
  216. {
  217. if ($this->organizationAddressPostals->removeElement($organizationAddressPostal)) {
  218. // $organizationAddressPostal->setAddressPostal(null); // TODO: actuellement, pas nullable: conserver?
  219. }
  220. return $this;
  221. }
  222. }