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.

205 lines
5.5KB

  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. use Lc\ShopBundle\Context\FilterMerchantInterface;
  7. use Lc\ShopBundle\Context\ReductionCatalogInterface;
  8. use Lc\ShopBundle\Context\ReductionInterface;
  9. use phpDocumentor\Reflection\Types\Integer;
  10. /**
  11. * @ORM\MappedSuperclass()
  12. */
  13. abstract class ReductionCatalog extends AbstractDocumentEntity implements ReductionCatalogInterface, FilterMerchantInterface
  14. {
  15. use ReductionTrait;
  16. /**
  17. * @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\MerchantInterface", inversedBy="productFamilies")
  18. * @ORM\JoinColumn(nullable=false)
  19. */
  20. protected $merchant;
  21. /**
  22. * @ORM\ManyToMany(targetEntity="Lc\ShopBundle\Context\ProductFamilyInterface")
  23. */
  24. protected $productFamilies;
  25. /**
  26. * @ORM\OneToOne(targetEntity="Lc\ShopBundle\Context\ProductFamilyInterface")
  27. */
  28. protected $productFamily;
  29. /**
  30. * @ORM\ManyToMany(targetEntity="Lc\ShopBundle\Context\ProductCategoryInterface")
  31. */
  32. protected $productCategories;
  33. /**
  34. * @ORM\ManyToMany(targetEntity="Lc\ShopBundle\Context\GroupUserInterface")
  35. */
  36. protected $groupUsers;
  37. /**
  38. * @ORM\ManyToMany(targetEntity="Lc\ShopBundle\Context\UserInterface")
  39. */
  40. protected $users;
  41. public function __construct()
  42. {
  43. $this->productFamilies = new ArrayCollection();
  44. $this->groupUsers = new ArrayCollection();
  45. $this->productCategories = new ArrayCollection();
  46. $this->users = new ArrayCollection();
  47. }
  48. public function getMerchant(): ?Merchant
  49. {
  50. return $this->merchant;
  51. }
  52. public function setMerchant(?Merchant $merchant): self
  53. {
  54. $this->merchant = $merchant;
  55. return $this;
  56. }
  57. /**
  58. * @return Collection|ProductFamily[]
  59. */
  60. public function getProductFamilies(): Collection
  61. {
  62. return $this->productFamilies;
  63. }
  64. public function addProductFamily(ProductFamily $productFamily): self
  65. {
  66. if (!$this->productFamilies->contains($productFamily)) {
  67. $this->productFamilies[] = $productFamily;
  68. }
  69. return $this;
  70. }
  71. public function removeProductFamily(ProductFamily $productFamily): self
  72. {
  73. if ($this->productFamilies->contains($productFamily)) {
  74. $this->productFamilies->removeElement($productFamily);
  75. }
  76. return $this;
  77. }
  78. public function getProductFamily(): ?ProductFamily
  79. {
  80. return $this->productFamily;
  81. }
  82. public function setProductFamily(?ProductFamily $productFamily): self
  83. {
  84. $this->productFamily = $productFamily;
  85. return $this;
  86. }
  87. /**
  88. * @return Collection|GroupUser[]
  89. */
  90. public function getGroupUsers(): Collection
  91. {
  92. return $this->groupUsers;
  93. }
  94. public function addGroupUser(GroupUser $groupUser): self
  95. {
  96. if (!$this->groupUsers->contains($groupUser)) {
  97. $this->groupUsers[] = $groupUser;
  98. }
  99. return $this;
  100. }
  101. public function removeGroupUser(GroupUser $groupUser): self
  102. {
  103. if ($this->groupUsers->contains($groupUser)) {
  104. $this->groupUsers->removeElement($groupUser);
  105. }
  106. return $this;
  107. }
  108. /**
  109. * @return Collection|ProductCategory[]
  110. */
  111. public function getProductCategories(): Collection
  112. {
  113. return $this->productCategories;
  114. }
  115. public function addProductCategory(ProductCategory $productCategory): self
  116. {
  117. if (!$this->productCategories->contains($productCategory)) {
  118. $this->productCategories[] = $productCategory;
  119. }
  120. return $this;
  121. }
  122. public function removeProductCategory(ProductCategory $productCategory): self
  123. {
  124. if ($this->productCategories->contains($productCategory)) {
  125. $this->productCategories->removeElement($productCategory);
  126. }
  127. return $this;
  128. }
  129. /**
  130. * @return Collection|User[]
  131. */
  132. public function getUsers(): Collection
  133. {
  134. return $this->users;
  135. }
  136. public function addUser(User $user): self
  137. {
  138. if (!$this->users->contains($user)) {
  139. $this->users[] = $user;
  140. }
  141. return $this;
  142. }
  143. public function removeUser(User $user): self
  144. {
  145. if ($this->users->contains($user)) {
  146. $this->users->removeElement($user);
  147. }
  148. return $this;
  149. }
  150. /*public function getFromQuantity(): ?int
  151. {
  152. return $this->fromQuantity;
  153. }
  154. public function setFromQuantity(int $fromQuantity): self
  155. {
  156. $this->fromQuantity = $fromQuantity;
  157. return $this;
  158. }*/
  159. }