No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

Address.php 8.6KB

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