vendor/sulu/sulu/src/Sulu/Bundle/ContactBundle/Entity/Address.php line 24

Open in your IDE?
  1. <?php
  2. /*
  3. * This file is part of Sulu.
  4. *
  5. * (c) Sulu GmbH
  6. *
  7. * This source file is subject to the MIT license that is bundled
  8. * with this source code in the file LICENSE.
  9. */
  10. namespace Sulu\Bundle\ContactBundle\Entity;
  11. use Doctrine\Common\Collections\ArrayCollection;
  12. use Doctrine\Common\Collections\Collection;
  13. use JMS\Serializer\Annotation\ExclusionPolicy;
  14. use JMS\Serializer\Annotation\Expose;
  15. use JMS\Serializer\Annotation\Groups;
  16. /**
  17. * Address.
  18. */
  19. #[ExclusionPolicy('all')] // ;
  20. class Address
  21. {
  22. /**
  23. * @var string|null
  24. */
  25. #[Groups(['fullAccount', 'partialAccount', 'fullContact', 'partialContact'])]
  26. #[Expose]
  27. private $street;
  28. /**
  29. * @var string|null
  30. */
  31. #[Groups(['fullAccount', 'partialAccount', 'fullContact', 'partialContact'])]
  32. #[Expose]
  33. private $number;
  34. /**
  35. * @var string|null
  36. */
  37. #[Groups(['fullAccount', 'partialAccount', 'fullContact', 'partialContact'])]
  38. #[Expose]
  39. private $addition;
  40. /**
  41. * @var string|null
  42. */
  43. #[Groups(['fullAccount', 'partialAccount', 'fullContact', 'partialContact'])]
  44. #[Expose]
  45. private $zip;
  46. /**
  47. * @var string|null
  48. */
  49. #[Groups(['fullAccount', 'partialAccount', 'fullContact', 'partialContact'])]
  50. #[Expose]
  51. private $city;
  52. /**
  53. * @var string|null
  54. */
  55. #[Groups(['fullAccount', 'partialAccount', 'fullContact', 'partialContact'])]
  56. #[Expose]
  57. private $state;
  58. /**
  59. * @var int
  60. */
  61. #[Groups(['fullAccount', 'partialAccount', 'fullContact', 'partialContact'])]
  62. #[Expose]
  63. private $id;
  64. /**
  65. * @var AddressType
  66. */
  67. #[Groups(['fullAccount', 'fullContact'])]
  68. #[Expose]
  69. private $addressType;
  70. /**
  71. * @var string|null
  72. */
  73. #[Groups(['fullAccount', 'partialAccount', 'fullContact', 'partialContact'])]
  74. #[Expose]
  75. private $countryCode;
  76. /**
  77. * @var bool|null
  78. */
  79. #[Groups(['fullAccount', 'partialAccount', 'fullContact', 'partialContact'])]
  80. #[Expose]
  81. private $primaryAddress;
  82. /**
  83. * @var bool|null
  84. */
  85. #[Groups(['fullAccount', 'partialAccount', 'fullContact', 'partialContact'])]
  86. #[Expose]
  87. private $deliveryAddress;
  88. /**
  89. * @var bool|null
  90. */
  91. #[Groups(['fullAccount', 'partialAccount', 'fullContact', 'partialContact'])]
  92. #[Expose]
  93. private $billingAddress;
  94. /**
  95. * @var string|null
  96. */
  97. #[Groups(['fullAccount', 'partialAccount', 'fullContact', 'partialContact'])]
  98. #[Expose]
  99. private $postboxNumber;
  100. /**
  101. * @var string|null
  102. */
  103. #[Groups(['fullAccount', 'partialAccount', 'fullContact', 'partialContact'])]
  104. #[Expose]
  105. private $postboxPostcode;
  106. /**
  107. * @var string|null
  108. */
  109. #[Groups(['fullAccount', 'partialAccount', 'fullContact', 'partialContact'])]
  110. #[Expose]
  111. private $postboxCity;
  112. /**
  113. * @var Collection<int, ContactAddress>
  114. */
  115. private $contactAddresses;
  116. /**
  117. * @var Collection<int, AccountAddress>
  118. */
  119. private $accountAddresses;
  120. /**
  121. * @var string|null
  122. */
  123. #[Groups(['fullAccount', 'partialAccount', 'fullContact', 'partialContact'])]
  124. #[Expose]
  125. private $note;
  126. /**
  127. * @var string|null
  128. */
  129. #[Groups(['fullAccount', 'partialAccount', 'fullContact', 'partialContact'])]
  130. #[Expose]
  131. private $title;
  132. /**
  133. * @var float|null
  134. */
  135. #[Groups(['fullAccount', 'partialAccount', 'fullContact', 'partialContact'])]
  136. #[Expose]
  137. private $latitude;
  138. /**
  139. * @var float|null
  140. */
  141. #[Groups(['fullAccount', 'partialAccount', 'fullContact', 'partialContact'])]
  142. #[Expose]
  143. private $longitude;
  144. /**
  145. * Constructor.
  146. */
  147. public function __construct()
  148. {
  149. $this->accountAddresses = new ArrayCollection();
  150. $this->contactAddresses = new ArrayCollection();
  151. }
  152. /**
  153. * Set street.
  154. *
  155. * @param string|null $street
  156. *
  157. * @return Address
  158. */
  159. public function setStreet($street)
  160. {
  161. $this->street = $street;
  162. return $this;
  163. }
  164. /**
  165. * Get street.
  166. *
  167. * @return string|null
  168. */
  169. public function getStreet()
  170. {
  171. return $this->street;
  172. }
  173. /**
  174. * Set number.
  175. *
  176. * @param string|null $number
  177. *
  178. * @return Address
  179. */
  180. public function setNumber($number)
  181. {
  182. $this->number = $number;
  183. return $this;
  184. }
  185. /**
  186. * Get number.
  187. *
  188. * @return string|null
  189. */
  190. public function getNumber()
  191. {
  192. return $this->number;
  193. }
  194. /**
  195. * Set addition.
  196. *
  197. * @param string|null $addition
  198. *
  199. * @return Address
  200. */
  201. public function setAddition($addition)
  202. {
  203. $this->addition = $addition;
  204. return $this;
  205. }
  206. /**
  207. * Get addition.
  208. *
  209. * @return string|null
  210. */
  211. public function getAddition()
  212. {
  213. return $this->addition;
  214. }
  215. /**
  216. * Set zip.
  217. *
  218. * @param string|null $zip
  219. *
  220. * @return Address
  221. */
  222. public function setZip($zip)
  223. {
  224. $this->zip = $zip;
  225. return $this;
  226. }
  227. /**
  228. * Get zip.
  229. *
  230. * @return string|null
  231. */
  232. public function getZip()
  233. {
  234. return $this->zip;
  235. }
  236. /**
  237. * Set city.
  238. *
  239. * @param string|null $city
  240. *
  241. * @return Address
  242. */
  243. public function setCity($city)
  244. {
  245. $this->city = $city;
  246. return $this;
  247. }
  248. /**
  249. * Get city.
  250. *
  251. * @return string|null
  252. */
  253. public function getCity()
  254. {
  255. return $this->city;
  256. }
  257. /**
  258. * Set state.
  259. *
  260. * @param string|null $state
  261. *
  262. * @return Address
  263. */
  264. public function setState($state)
  265. {
  266. $this->state = $state;
  267. return $this;
  268. }
  269. /**
  270. * Get state.
  271. *
  272. * @return string|null
  273. */
  274. public function getState()
  275. {
  276. return $this->state;
  277. }
  278. /**
  279. * Get id.
  280. *
  281. * @return int
  282. */
  283. public function getId()
  284. {
  285. return $this->id;
  286. }
  287. /**
  288. * Set addressType.
  289. *
  290. * @return Address
  291. */
  292. public function setAddressType(AddressType $addressType)
  293. {
  294. $this->addressType = $addressType;
  295. return $this;
  296. }
  297. /**
  298. * Get addressType.
  299. *
  300. * @return AddressType
  301. */
  302. public function getAddressType()
  303. {
  304. return $this->addressType;
  305. }
  306. /**
  307. * Set countryCode.
  308. *
  309. * @return Address
  310. */
  311. public function setCountryCode(?string $countryCode)
  312. {
  313. $this->countryCode = $countryCode;
  314. return $this;
  315. }
  316. /**
  317. * Get countryCode.
  318. */
  319. public function getCountryCode(): ?string
  320. {
  321. return $this->countryCode;
  322. }
  323. public function getCountry(): ?Country
  324. {
  325. if (!$this->countryCode) {
  326. return null;
  327. }
  328. return new Country($this->countryCode);
  329. }
  330. /**
  331. * Set primaryAddress.
  332. *
  333. * @param bool $primaryAddress
  334. *
  335. * @return Address
  336. */
  337. public function setPrimaryAddress($primaryAddress)
  338. {
  339. $this->primaryAddress = $primaryAddress;
  340. return $this;
  341. }
  342. /**
  343. * Get primaryAddress.
  344. *
  345. * @return bool|null
  346. */
  347. public function getPrimaryAddress()
  348. {
  349. return $this->primaryAddress;
  350. }
  351. /**
  352. * Set deliveryAddress.
  353. *
  354. * @param bool $deliveryAddress
  355. *
  356. * @return Address
  357. */
  358. public function setDeliveryAddress($deliveryAddress)
  359. {
  360. $this->deliveryAddress = $deliveryAddress;
  361. return $this;
  362. }
  363. /**
  364. * Get deliveryAddress.
  365. *
  366. * @return bool|null
  367. */
  368. public function getDeliveryAddress()
  369. {
  370. return $this->deliveryAddress;
  371. }
  372. /**
  373. * Set billingAddress.
  374. *
  375. * @param bool $billingAddress
  376. *
  377. * @return Address
  378. */
  379. public function setBillingAddress($billingAddress)
  380. {
  381. $this->billingAddress = $billingAddress;
  382. return $this;
  383. }
  384. /**
  385. * Get billingAddress.
  386. *
  387. * @return bool|null
  388. */
  389. public function getBillingAddress()
  390. {
  391. return $this->billingAddress;
  392. }
  393. /**
  394. * Set postboxNumber.
  395. *
  396. * @param string|null $postboxNumber
  397. *
  398. * @return Address
  399. */
  400. public function setPostboxNumber($postboxNumber)
  401. {
  402. $this->postboxNumber = $postboxNumber;
  403. return $this;
  404. }
  405. /**
  406. * Get postboxNumber.
  407. *
  408. * @return string|null
  409. */
  410. public function getPostboxNumber()
  411. {
  412. return $this->postboxNumber;
  413. }
  414. /**
  415. * Set postboxPostcode.
  416. *
  417. * @param string|null $postboxPostcode
  418. *
  419. * @return Address
  420. */
  421. public function setPostboxPostcode($postboxPostcode)
  422. {
  423. $this->postboxPostcode = $postboxPostcode;
  424. return $this;
  425. }
  426. /**
  427. * Get postboxPostcode.
  428. *
  429. * @return string|null
  430. */
  431. public function getPostboxPostcode()
  432. {
  433. return $this->postboxPostcode;
  434. }
  435. /**
  436. * Set postboxCity.
  437. *
  438. * @param string|null $postboxCity
  439. *
  440. * @return Address
  441. */
  442. public function setPostboxCity($postboxCity)
  443. {
  444. $this->postboxCity = $postboxCity;
  445. return $this;
  446. }
  447. /**
  448. * Get postboxCity.
  449. *
  450. * @return string|null
  451. */
  452. public function getPostboxCity()
  453. {
  454. return $this->postboxCity;
  455. }
  456. /**
  457. * Add contactAddresses.
  458. *
  459. * @return Address
  460. */
  461. public function addContactAddress(ContactAddress $contactAddresses)
  462. {
  463. $this->contactAddresses[] = $contactAddresses;
  464. return $this;
  465. }
  466. /**
  467. * Remove contactAddresses.
  468. *
  469. * @return void
  470. */
  471. public function removeContactAddress(ContactAddress $contactAddresses)
  472. {
  473. $this->contactAddresses->removeElement($contactAddresses);
  474. }
  475. /**
  476. * Get contactAddresses.
  477. *
  478. * @return Collection<int, ContactAddress>
  479. */
  480. public function getContactAddresses()
  481. {
  482. return $this->contactAddresses;
  483. }
  484. /**
  485. * Add accountAddresses.
  486. *
  487. * @return Address
  488. */
  489. public function addAccountAddress(AccountAddress $accountAddresses)
  490. {
  491. $this->accountAddresses[] = $accountAddresses;
  492. return $this;
  493. }
  494. /**
  495. * Remove accountAddresses.
  496. */
  497. public function removeAccountAddress(AccountAddress $accountAddresses)
  498. {
  499. $this->accountAddresses->removeElement($accountAddresses);
  500. }
  501. /**
  502. * Get accountAddresses.
  503. *
  504. * @return Collection<int, AccountAddress>
  505. */
  506. public function getAccountAddresses()
  507. {
  508. return $this->accountAddresses;
  509. }
  510. /**
  511. * returns if address has at least one relation to another entity.
  512. *
  513. * @return bool
  514. */
  515. public function hasRelations()
  516. {
  517. if (!$this->getContactAddresses()->isEmpty()
  518. || !$this->getAccountAddresses()->isEmpty()
  519. ) {
  520. return true;
  521. }
  522. return false;
  523. }
  524. /**
  525. * Set note.
  526. *
  527. * @param string|null $note
  528. *
  529. * @return Address
  530. */
  531. public function setNote($note)
  532. {
  533. $this->note = $note;
  534. return $this;
  535. }
  536. /**
  537. * Get note.
  538. *
  539. * @return string|null
  540. */
  541. public function getNote()
  542. {
  543. return $this->note;
  544. }
  545. /**
  546. * Set title.
  547. *
  548. * @param string|null $title
  549. *
  550. * @return Address
  551. */
  552. public function setTitle($title)
  553. {
  554. $this->title = $title;
  555. return $this;
  556. }
  557. /**
  558. * Get title.
  559. *
  560. * @return string|null
  561. */
  562. public function getTitle()
  563. {
  564. return $this->title;
  565. }
  566. /**
  567. * Returns latitude.
  568. *
  569. * @return float|null
  570. */
  571. public function getLatitude()
  572. {
  573. return $this->latitude;
  574. }
  575. /**
  576. * Set latitude.
  577. *
  578. * @param float|null $latitude
  579. *
  580. * @return Address
  581. */
  582. public function setLatitude($latitude)
  583. {
  584. $this->latitude = $latitude;
  585. return $this;
  586. }
  587. /**
  588. * Returns longitude.
  589. *
  590. * @return float|null
  591. */
  592. public function getLongitude()
  593. {
  594. return $this->longitude;
  595. }
  596. /**
  597. * Set longitude.
  598. *
  599. * @param float|null $longitude
  600. *
  601. * @return Address
  602. */
  603. public function setLongitude($longitude)
  604. {
  605. $this->longitude = $longitude;
  606. return $this;
  607. }
  608. }