Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

155 lines
4.3KB

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