You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

179 line
5.4KB

  1. <?php
  2. namespace Lc\ShopBundle\Model;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. /**
  7. * @ORM\MappedSuperclass()
  8. */
  9. abstract class Merchant extends AbstractDocumentEntity
  10. {
  11. /**
  12. * @ORM\OneToOne(targetEntity="Lc\ShopBundle\Context\CreditConfigInterface", cascade={"persist", "remove"})
  13. * @ORM\JoinColumn(nullable=true)
  14. */
  15. protected $creditConfig;
  16. /**
  17. * @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\TaxRateInterface")
  18. * @ORM\JoinColumn(nullable=false)
  19. */
  20. protected $taxRate;
  21. /**
  22. * @ORM\ManyToMany(targetEntity="Lc\ShopBundle\Context\PointSaleInterface", mappedBy="merchant")
  23. */
  24. protected $pointSales;
  25. /**
  26. * @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\ProductFamilyInterface", mappedBy="merchant")
  27. */
  28. protected $productFamilies;
  29. /**
  30. * @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\MerchantConfigInterface", mappedBy="merchant", orphanRemoval=true)
  31. */
  32. protected $merchantConfigs;
  33. /**
  34. * @ORM\OneToOne(targetEntity="Lc\ShopBundle\Context\AddressInterface", inversedBy="merchant", cascade={"persist", "remove"})
  35. * @ORM\JoinColumn(nullable=true)
  36. */
  37. protected $address;
  38. public function __construct()
  39. {
  40. $this->pointSales = new ArrayCollection();
  41. $this->productFamilies = new ArrayCollection();
  42. $this->merchantConfigs = new ArrayCollection();
  43. }
  44. public function getCreditConfig(): ?CreditConfig
  45. {
  46. return $this->creditConfig;
  47. }
  48. public function setCreditConfig(CreditConfig $creditConfig): self
  49. {
  50. $this->creditConfig = $creditConfig;
  51. return $this;
  52. }
  53. public function getTaxRate(): ?TaxRate
  54. {
  55. return $this->taxRate;
  56. }
  57. public function setTaxRate(?TaxRate $taxRate): self
  58. {
  59. $this->taxRate = $taxRate;
  60. return $this;
  61. }
  62. /**
  63. * @return Collection|PointSale[]
  64. */
  65. public function getPointSales(): Collection
  66. {
  67. return $this->pointSales;
  68. }
  69. public function addPointSale(PointSale $pointSale): self
  70. {
  71. if (!$this->pointSales->contains($pointSale)) {
  72. $this->pointSales[] = $pointSale;
  73. $pointSale->addMerchant($this);
  74. }
  75. return $this;
  76. }
  77. public function removePointSale(PointSale $pointSale): self
  78. {
  79. if ($this->pointSales->contains($pointSale)) {
  80. $this->pointSales->removeElement($pointSale);
  81. $pointSale->removeMerchant($this);
  82. }
  83. return $this;
  84. }
  85. /**
  86. * @return Collection|ProductFamily[]
  87. */
  88. public function getProductFamilies(): Collection
  89. {
  90. return $this->productFamilies;
  91. }
  92. public function addProductFamily(ProductFamily $productFamily): self
  93. {
  94. if (!$this->productFamilies->contains($productFamily)) {
  95. $this->productFamilies[] = $productFamily;
  96. $productFamily->setMerchant($this);
  97. }
  98. return $this;
  99. }
  100. public function removeProductFamily(ProductFamily $productFamily): self
  101. {
  102. if ($this->productFamilies->contains($productFamily)) {
  103. $this->productFamilies->removeElement($productFamily);
  104. // set the owning side to null (unless already changed)
  105. if ($productFamily->getMerchant() === $this) {
  106. $productFamily->setMerchant(null);
  107. }
  108. }
  109. return $this;
  110. }
  111. /**
  112. * @return Collection|MerchantConfig[]
  113. */
  114. public function getMerchantConfigs(): Collection
  115. {
  116. return $this->merchantConfigs;
  117. }
  118. public function addMerchantConfig(MerchantConfig $merchantConfig): self
  119. {
  120. if (!$this->merchantConfigs->contains($merchantConfig)) {
  121. $this->merchantConfigs[] = $merchantConfig;
  122. $merchantConfig->setMerchant($this);
  123. }
  124. return $this;
  125. }
  126. public function removeMerchantConfig(MerchantConfig $merchantConfig): self
  127. {
  128. if ($this->merchantConfigs->contains($merchantConfig)) {
  129. $this->merchantConfigs->removeElement($merchantConfig);
  130. // set the owning side to null (unless already changed)
  131. if ($merchantConfig->getMerchant() === $this) {
  132. $merchantConfig->setMerchant(null);
  133. }
  134. }
  135. return $this;
  136. }
  137. public function getAddress(): ?Address
  138. {
  139. return $this->address;
  140. }
  141. public function setAddress(Address $address): self
  142. {
  143. $this->address = $address;
  144. return $this;
  145. }
  146. }