Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

PointSaleModel.php 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <?php
  2. namespace Lc\CaracoleBundle\Model\PointSale;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Lc\CaracoleBundle\Doctrine\Extension\FilterMultipleMerchantsInterface;
  7. use Lc\CaracoleBundle\Doctrine\Extension\OrderAmountMinTrait;
  8. use Lc\CaracoleBundle\Doctrine\Extension\OrderAmountMinInterface;
  9. use Lc\CaracoleBundle\Model\Address\AddressInterface;
  10. use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
  11. use Lc\CaracoleBundle\Model\User\UserPointSaleInterface;
  12. use Lc\SovBundle\Doctrine\Pattern\AbstractFullEntity;
  13. /**
  14. * @ORM\MappedSuperclass()
  15. */
  16. abstract class PointSaleModel extends AbstractFullEntity implements FilterMultipleMerchantsInterface,
  17. OrderAmountMinInterface
  18. {
  19. use OrderAmountMinTrait;
  20. /**
  21. * @ORM\ManyToMany(targetEntity="Lc\CaracoleBundle\Model\Merchant\MerchantInterface", inversedBy="pointSales")
  22. */
  23. protected $merchants;
  24. /**
  25. * @ORM\Column(type="string", length=63, nullable=true)
  26. */
  27. protected $code;
  28. /**
  29. * @ORM\OneToOne(targetEntity="Lc\CaracoleBundle\Model\Address\AddressInterface", inversedBy="pointSale", cascade={"persist", "remove"})
  30. * @ORM\JoinColumn(nullable=false)
  31. */
  32. protected $address;
  33. /**
  34. * @ORM\OneToMany(targetEntity="Lc\CaracoleBundle\Model\User\UserPointSaleInterface", mappedBy="pointSale", orphanRemoval=true)
  35. */
  36. protected $userPointSales;
  37. public function __construct()
  38. {
  39. $this->merchants = new ArrayCollection();
  40. $this->userPointSales = new ArrayCollection();
  41. }
  42. public function __toString()
  43. {
  44. return $this->getTitle();
  45. }
  46. public function labelAdminChoice()
  47. {
  48. return $this->getTitle();
  49. }
  50. /**
  51. * @return Collection|MerchantInterface[]
  52. */
  53. public function getMerchants(): Collection
  54. {
  55. return $this->merchants;
  56. }
  57. public function addMerchant(MerchantInterface $merchant): self
  58. {
  59. if (!$this->merchants->contains($merchant)) {
  60. $this->merchants[] = $merchant;
  61. }
  62. return $this;
  63. }
  64. public function removeMerchant(MerchantInterface $merchant): self
  65. {
  66. if ($this->merchants->contains($merchant)) {
  67. $this->merchants->removeElement($merchant);
  68. }
  69. return $this;
  70. }
  71. public function getCode(): ?string
  72. {
  73. return $this->code;
  74. }
  75. public function setCode(?string $code): self
  76. {
  77. $this->code = $code;
  78. return $this;
  79. }
  80. public function getAddress(): ?AddressInterface
  81. {
  82. return $this->address;
  83. }
  84. public function setAddress(AddressInterface $address): self
  85. {
  86. $this->address = $address;
  87. return $this;
  88. }
  89. /**
  90. * @return Collection|UserPointSaleInterface[]
  91. */
  92. public function getUserPointSales(): Collection
  93. {
  94. return $this->userPointSales;
  95. }
  96. public function addUserPointSale(UserPointSaleInterface $userPointSale): self
  97. {
  98. if (!$this->userPointSales->contains($userPointSale)) {
  99. $this->userPointSales[] = $userPointSale;
  100. $userPointSale->setPointSale($this);
  101. }
  102. return $this;
  103. }
  104. public function removeUserPointSale(UserPointSaleInterface $userPointSale): self
  105. {
  106. if ($this->userPointSales->contains($userPointSale)) {
  107. $this->userPointSales->removeElement($userPointSale);
  108. // set the owning side to null (unless already changed)
  109. if ($userPointSale->getPointSale() === $this) {
  110. $userPointSale->setPointSale(null);
  111. }
  112. }
  113. return $this;
  114. }
  115. }