Address.php 8.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  1. <?php
  2. namespace Lc\ShopBundle\Model;
  3. use Doctrine\ORM\Mapping as ORM;
  4. /**
  5. * @ORM\MappedSuperclass()
  6. */
  7. abstract class Address extends AbstractEntity
  8. {
  9. /**
  10. * @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\UserInterface", inversedBy="addresses")
  11. * @ORM\JoinColumn(nullable=true)
  12. */
  13. protected $user;
  14. /**
  15. * @ORM\Column(type="string", length=255)
  16. */
  17. protected $title;
  18. /**
  19. * @ORM\Column(type="string", length=31)
  20. */
  21. protected $type;
  22. /**
  23. * @ORM\Column(type="boolean", nullable=true)
  24. */
  25. protected $civility;
  26. /**
  27. * @ORM\Column(type="string", length=127, nullable=true)
  28. */
  29. protected $lastname;
  30. /**
  31. * @ORM\Column(type="string", length=127, nullable=true)
  32. */
  33. protected $firstname;
  34. /**
  35. * @ORM\Column(type="text")
  36. */
  37. protected $address;
  38. /**
  39. * @ORM\Column(type="string", length=31)
  40. */
  41. protected $zip;
  42. /**
  43. * @ORM\Column(type="string", length=255)
  44. */
  45. protected $city;
  46. /**
  47. * @ORM\Column(type="string", length=255)
  48. */
  49. protected $country;
  50. /**
  51. * @ORM\Column(type="string", length=255, nullable=true)
  52. */
  53. protected $company;
  54. /**
  55. * @ORM\Column(type="string", length=127, nullable=true)
  56. */
  57. protected $siret;
  58. /**
  59. * @ORM\Column(type="string", length=127, nullable=true)
  60. */
  61. protected $tva;
  62. /**
  63. * @ORM\Column(type="array", nullable=true)
  64. */
  65. protected $phone;
  66. /**
  67. * @ORM\Column(type="text", nullable=true)
  68. */
  69. protected $comment;
  70. /**
  71. * @ORM\OneToOne(targetEntity="Lc\ShopBundle\Context\PointSaleInterface", mappedBy="address", cascade={"persist", "remove"})
  72. */
  73. protected $pointSale;
  74. /**
  75. * @ORM\OneToOne(targetEntity="Lc\ShopBundle\Context\MerchantInterface", mappedBy="address", cascade={"persist", "remove"})
  76. */
  77. protected $merchant;
  78. /**
  79. * @ORM\Column(type="text", nullable=true)
  80. */
  81. protected $deliveryInfos;
  82. public function __construct()
  83. {
  84. $this->phone = [] ;
  85. }
  86. public function __toString()
  87. {
  88. return $this->getTitle() . ' - ' . $this->getZip() . ' ' . $this->getCity();
  89. }
  90. public function getSummaryShort()
  91. {
  92. return $this->getAddress() . ' - ' . $this->getZip() . ' ' . $this->getCity();
  93. }
  94. public function getSummary()
  95. {
  96. $html = '';
  97. if ($this->getTitle()) {
  98. $html .= $this->getTitle() . '<br />';
  99. }
  100. if ($this->getLastname() || $this->getFirstname()) {
  101. $html .= $this->getLastname() . ' ' . $this->getFirstname() . '<br />';
  102. }
  103. if ($this->getAddress()) {
  104. $html .= $this->getAddress() . '<br />';
  105. }
  106. if ($this->getZip() || $this->getCity()) {
  107. $html .= $this->getZip() . ' ' . $this->getCity() . '<br />';
  108. }
  109. if ($this->getPhone()) {
  110. foreach($this->getPhone() as $phone) {
  111. $html .= 'Tél. ' . $phone.'<br />';
  112. }
  113. }
  114. return $html;
  115. }
  116. public function getUser(): ?User
  117. {
  118. return $this->user;
  119. }
  120. public function setUser(?User $user): self
  121. {
  122. $this->user = $user;
  123. return $this;
  124. }
  125. public function getTitle(): ?string
  126. {
  127. return $this->title;
  128. }
  129. public function setTitle(string $title): self
  130. {
  131. $this->title = $title;
  132. return $this;
  133. }
  134. public function getType(): ?string
  135. {
  136. return $this->type;
  137. }
  138. public function setType(string $type): self
  139. {
  140. $this->type = $type;
  141. return $this;
  142. }
  143. public function getCivility(): ?bool
  144. {
  145. return $this->civility;
  146. }
  147. public function setCivility(?bool $civility): self
  148. {
  149. $this->civility = $civility;
  150. return $this;
  151. }
  152. public function getLastname(): ?string
  153. {
  154. return $this->lastname;
  155. }
  156. public function setLastname(?string $lastname): self
  157. {
  158. $this->lastname = $lastname;
  159. return $this;
  160. }
  161. public function getFirstname(): ?string
  162. {
  163. return $this->firstname;
  164. }
  165. public function setFirstname(?string $firstname): self
  166. {
  167. $this->firstname = $firstname;
  168. return $this;
  169. }
  170. public function getAddress(): ?string
  171. {
  172. return $this->address;
  173. }
  174. public function setAddress(string $address): self
  175. {
  176. $this->address = $address;
  177. return $this;
  178. }
  179. public function getZip(): ?string
  180. {
  181. return $this->zip;
  182. }
  183. public function setZip(string $zip): self
  184. {
  185. $this->zip = $zip;
  186. return $this;
  187. }
  188. public function getCity(): ?string
  189. {
  190. return $this->city;
  191. }
  192. public function setCity(string $city): self
  193. {
  194. $this->city = $city;
  195. return $this;
  196. }
  197. public function getCountry(): ?string
  198. {
  199. return $this->country;
  200. }
  201. public function setCountry(string $country): self
  202. {
  203. $this->country = $country;
  204. return $this;
  205. }
  206. public function getCompany(): ?string
  207. {
  208. return $this->company;
  209. }
  210. public function setCompany(?string $company): self
  211. {
  212. $this->company = $company;
  213. return $this;
  214. }
  215. public function getSiret(): ?string
  216. {
  217. return $this->siret;
  218. }
  219. public function setSiret(?string $siret): self
  220. {
  221. $this->siret = $siret;
  222. return $this;
  223. }
  224. public function getTva(): ?string
  225. {
  226. return $this->tva;
  227. }
  228. public function setTva(?string $tva): self
  229. {
  230. $this->tva = $tva;
  231. return $this;
  232. }
  233. public function getPhone(): ?array
  234. {
  235. return $this->phone;
  236. }
  237. public function setPhone(?array $phone): self
  238. {
  239. $this->phone = $phone;
  240. return $this;
  241. }
  242. public function getComment(): ?string
  243. {
  244. return $this->comment;
  245. }
  246. public function setComment(?string $comment): self
  247. {
  248. $this->comment = $comment;
  249. return $this;
  250. }
  251. public function getPointSale(): ?PointSale
  252. {
  253. return $this->pointSale;
  254. }
  255. public function setPointSale(PointSale $pointSale): self
  256. {
  257. $this->pointSale = $pointSale;
  258. // set the owning side of the relation if necessary
  259. if ($pointSale->getAddress() !== $this) {
  260. $pointSale->setAddress($this);
  261. }
  262. return $this;
  263. }
  264. public function getMerchant(): ?Merchant
  265. {
  266. return $this->merchant;
  267. }
  268. public function setMerchant(Merchant $merchant): self
  269. {
  270. $this->merchant = $merchant;
  271. // set the owning side of the relation if necessary
  272. if ($merchant->getAddress() !== $this) {
  273. $merchant->setAddress($this);
  274. }
  275. return $this;
  276. }
  277. public function getDeliveryInfos(): ?string
  278. {
  279. return $this->deliveryInfos;
  280. }
  281. public function setDeliveryInfos(?string $deliveryInfos): self
  282. {
  283. $this->deliveryInfos = $deliveryInfos;
  284. return $this;
  285. }
  286. }