Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

156 lines
4.2KB

  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\FilterSectionInterface;
  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\Product\ProductCategoryInterface;
  11. use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface;
  12. use Lc\CaracoleBundle\Model\Product\ProductFamilyModel;
  13. use Lc\CaracoleBundle\Model\Section\SectionInterface;
  14. use Lc\SovBundle\Doctrine\Extension\StatusInterface;
  15. use Lc\SovBundle\Doctrine\Extension\StatusTrait;
  16. use Lc\SovBundle\Doctrine\Pattern\AbstractLightEntity;
  17. /**
  18. * @ORM\MappedSuperclass()
  19. */
  20. abstract class ReductionCatalogModel extends AbstractLightEntity implements ReductionCatalogInterface,
  21. ReductionPropertyInterface,
  22. FilterSectionInterface, 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\Section\SectionInterface")
  35. * @ORM\JoinColumn(nullable=false)
  36. */
  37. protected $section;
  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 getSection(): SectionInterface
  66. {
  67. return $this->section;
  68. }
  69. public function setSection(SectionInterface $section): self
  70. {
  71. $this->section = $section;
  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(): ?ProductFamilyModel
  96. {
  97. return $this->productFamily;
  98. }
  99. public function setProductFamily(?ProductFamilyModel $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. }