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.

преди 3 години
преди 3 години
преди 3 години
преди 3 години
преди 3 години
преди 3 години
преди 3 години
преди 3 години
преди 3 години
преди 3 години
преди 3 години
преди 3 години
преди 3 години
преди 3 години
преди 3 години
преди 3 години
преди 3 години
преди 3 години
преди 3 години
преди 3 години
преди 3 години
преди 3 години
преди 3 години
преди 3 години
преди 3 години
преди 3 години
преди 3 години
преди 3 години
преди 3 години
преди 3 години
преди 3 години
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. <?php
  2. namespace Lc\CaracoleBundle\Model\Section;
  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\Model\Merchant\MerchantInterface;
  8. use Lc\CaracoleBundle\Model\Order\OrderShopInterface;
  9. use Lc\CaracoleBundle\Model\Product\ProductCategoryInterface;
  10. use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface;
  11. use Lc\CaracoleBundle\Model\Site\PageInterface;
  12. use Lc\SovBundle\Doctrine\Pattern\AbstractFullEntity;
  13. /**
  14. * @ORM\MappedSuperclass()
  15. */
  16. abstract class SectionModel extends AbstractFullEntity implements FilterMerchantInterface
  17. {
  18. /**
  19. * @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Merchant\MerchantInterface")
  20. * @ORM\JoinColumn(nullable=false)
  21. */
  22. protected $merchant;
  23. /**
  24. * @ORM\Column(type="string", length=32)
  25. */
  26. protected $cycle;
  27. const SECTION_CYCLE_DAY = 'day';
  28. const SECTION_CYCLE_WEEK = 'week';
  29. const SECTION_CYCLE_MONTH = 'month';
  30. const SECTION_CYCLE_YEAR = 'year';
  31. /**
  32. * @ORM\ManyToMany(targetEntity="Lc\CaracoleBundle\Model\Product\ProductFamilyInterface", mappedBy="sections")
  33. */
  34. protected $productFamilies;
  35. /**
  36. * @ORM\OneToMany(targetEntity="Lc\CaracoleBundle\Model\Order\OrderShopInterface", mappedBy="section")
  37. */
  38. protected $orderShops;
  39. /**
  40. * @ORM\OneToMany(targetEntity="Lc\CaracoleBundle\Model\Product\ProductCategoryInterface", mappedBy="section")
  41. */
  42. protected $productCategories;
  43. /**
  44. * @ORM\OneToMany(targetEntity="Lc\CaracoleBundle\Model\Site\PageInterface", mappedBy="section")
  45. */
  46. protected $pages;
  47. public function __construct()
  48. {
  49. $this->productFamilies = new ArrayCollection();
  50. $this->orderShops = new ArrayCollection();
  51. }
  52. public function __toString()
  53. {
  54. return $this->getTitle();
  55. }
  56. public function getMerchant(): ?MerchantInterface
  57. {
  58. return $this->merchant;
  59. }
  60. public function setMerchant(?MerchantInterface $merchant): self
  61. {
  62. $this->merchant = $merchant;
  63. return $this;
  64. }
  65. public function getCycle(): ?string
  66. {
  67. return $this->cycle;
  68. }
  69. public function setCycle(string $cycle): self
  70. {
  71. $this->cycle = $cycle;
  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. $productFamily->addSection($this);
  86. }
  87. return $this;
  88. }
  89. public function removeProductFamily(ProductFamilyInterface $productFamily): self
  90. {
  91. if ($this->productFamilies->contains($productFamily)) {
  92. $this->productFamilies->removeElement($productFamily);
  93. $productFamily->removeSection($this);
  94. }
  95. return $this;
  96. }
  97. /**
  98. * @return Collection|OrderShopInterface[]
  99. */
  100. public function getOrderShops(): Collection
  101. {
  102. return $this->orderShops;
  103. }
  104. public function addOrderShop(OrderShopInterface $orderShop): self
  105. {
  106. if (!$this->orderShops->contains($orderShop)) {
  107. $this->orderShops[] = $orderShop;
  108. $orderShop->setSection($this);
  109. }
  110. return $this;
  111. }
  112. public function removeOrderShop(OrderShopInterface $orderShop): self
  113. {
  114. if ($this->orderShops->contains($orderShop)) {
  115. $this->orderShops->removeElement($orderShop);
  116. // set the owning side to null (unless already changed)
  117. if ($orderShop->getSection() === $this) {
  118. $orderShop->setSection(null);
  119. }
  120. }
  121. return $this;
  122. }
  123. /**
  124. * @return Collection|ProductCategoryInterface[]
  125. */
  126. public function getProductCategories(): Collection
  127. {
  128. return $this->productCategories;
  129. }
  130. public function addProductCategory(ProductCategoryInterface $productCategory): self
  131. {
  132. if (!$this->productCategories->contains($productCategory)) {
  133. $this->productCategories[] = $productCategory;
  134. $productCategory->setSection($this);
  135. }
  136. return $this;
  137. }
  138. public function removeProductCategory(ProductCategoryInterface $productCategory): self
  139. {
  140. if ($this->productCategories->contains($productCategory)) {
  141. $this->productCategories->removeElement($productCategory);
  142. // set the owning side to null (unless already changed)
  143. if ($productCategory->getSection() === $this) {
  144. $productCategory->setSection(null);
  145. }
  146. }
  147. return $this;
  148. }
  149. /**
  150. * @return Collection|PageInterface[]
  151. */
  152. public function getPages(): Collection
  153. {
  154. return $this->pages;
  155. }
  156. public function addPage(PageInterface $page): self
  157. {
  158. if (!$this->pages->contains($page)) {
  159. $this->pages[] = $page;
  160. $page->setSection($this);
  161. }
  162. return $this;
  163. }
  164. public function removePage(PageInterface $page): self
  165. {
  166. if ($this->pages->removeElement($page)) {
  167. // set the owning side to null (unless already changed)
  168. if ($page->getSection() === $this) {
  169. $page->setSection(null);
  170. }
  171. }
  172. return $this;
  173. }
  174. }