153 lines
4.2KB

  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 Lc\ShopBundle\Context\ReductionPropertyInterface;
  10. use Lc\ShopBundle\Context\StatusInterface;
  11. use phpDocumentor\Reflection\Types\Integer;
  12. /**
  13. * @ORM\MappedSuperclass()
  14. */
  15. abstract class ReductionCatalog extends AbstractEntity implements ReductionCatalogInterface, ReductionPropertyInterface, FilterMerchantInterface, StatusInterface
  16. {
  17. use StatusTrait;
  18. use ReductionTrait;
  19. use ReductionPropertyTrait{
  20. ReductionPropertyTrait::__construct as private __reductionPropertyConstruct;
  21. }
  22. /**
  23. * @ORM\Column(type="string", length=255)
  24. */
  25. protected $title;
  26. /**
  27. * @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\MerchantInterface")
  28. * @ORM\JoinColumn(nullable=false)
  29. */
  30. protected $merchant;
  31. /**
  32. * @ORM\ManyToMany(targetEntity="Lc\ShopBundle\Context\ProductFamilyInterface")
  33. */
  34. protected $productFamilies;
  35. /**
  36. * @ORM\OneToOne(targetEntity="Lc\ShopBundle\Context\ProductFamilyInterface")
  37. */
  38. protected $productFamily;
  39. /**
  40. * @ORM\ManyToMany(targetEntity="Lc\ShopBundle\Context\ProductCategoryInterface")
  41. */
  42. protected $productCategories;
  43. public function __construct()
  44. {
  45. $this->__reductionPropertyConstruct();
  46. $this->productFamilies = new ArrayCollection();
  47. $this->productCategories = new ArrayCollection();
  48. }
  49. public function getTitle(): ?string
  50. {
  51. return $this->title;
  52. }
  53. public function setTitle(string $title): self
  54. {
  55. $this->title = $title;
  56. return $this;
  57. }
  58. public function getMerchant(): ?Merchant
  59. {
  60. return $this->merchant;
  61. }
  62. public function setMerchant(?Merchant $merchant): self
  63. {
  64. $this->merchant = $merchant;
  65. return $this;
  66. }
  67. /**
  68. * @return Collection|ProductFamily[]
  69. */
  70. public function getProductFamilies(): Collection
  71. {
  72. return $this->productFamilies;
  73. }
  74. public function addProductFamily(ProductFamily $productFamily): self
  75. {
  76. if (!$this->productFamilies->contains($productFamily)) {
  77. $this->productFamilies[] = $productFamily;
  78. }
  79. return $this;
  80. }
  81. public function removeProductFamily(ProductFamily $productFamily): self
  82. {
  83. if ($this->productFamilies->contains($productFamily)) {
  84. $this->productFamilies->removeElement($productFamily);
  85. }
  86. return $this;
  87. }
  88. public function getProductFamily(): ?ProductFamily
  89. {
  90. return $this->productFamily;
  91. }
  92. public function setProductFamily(?ProductFamily $productFamily): self
  93. {
  94. $this->productFamily = $productFamily;
  95. return $this;
  96. }
  97. /**
  98. * @return Collection|ProductCategory[]
  99. */
  100. public function getProductCategories(): Collection
  101. {
  102. return $this->productCategories;
  103. }
  104. public function addProductCategory(ProductCategory $productCategory): self
  105. {
  106. if (!$this->productCategories->contains($productCategory)) {
  107. $this->productCategories[] = $productCategory;
  108. }
  109. return $this;
  110. }
  111. public function removeProductCategory(ProductCategory $productCategory): self
  112. {
  113. if ($this->productCategories->contains($productCategory)) {
  114. $this->productCategories->removeElement($productCategory);
  115. }
  116. return $this;
  117. }
  118. }