Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

SectionModel.php 7.3KB

vor 3 Jahren
vor 3 Jahren
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  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\Setting\EntitySettingTrait;
  12. use Lc\CaracoleBundle\Model\Setting\SectionSettingInterface;
  13. use Lc\SovBundle\Model\Site\PageInterface;
  14. use Lc\SovBundle\Doctrine\Pattern\AbstractFullEntity;
  15. /**
  16. * @ORM\MappedSuperclass()
  17. */
  18. abstract class SectionModel extends AbstractFullEntity implements FilterMerchantInterface
  19. {
  20. use EntitySettingTrait;
  21. /**
  22. * @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Merchant\MerchantInterface")
  23. * @ORM\JoinColumn(nullable=false)
  24. */
  25. protected $merchant;
  26. /**
  27. * @ORM\Column(type="string", length=32)
  28. */
  29. protected $cycle;
  30. const CYCLE_DAY = 'day';
  31. const CYCLE_WEEK = 'week';
  32. const CYCLE_MONTH = 'month';
  33. const CYCLE_YEAR = 'year';
  34. /**
  35. * @ORM\Column(type="boolean", nullable=true)
  36. */
  37. protected $isDefault;
  38. /**
  39. * @ORM\Column(type="string", length=32)
  40. */
  41. protected $color;
  42. /**
  43. * @ORM\ManyToMany(targetEntity="Lc\CaracoleBundle\Model\Product\ProductFamilyInterface", mappedBy="sections")
  44. */
  45. protected $productFamilies;
  46. /**
  47. * @ORM\OneToMany(targetEntity="Lc\CaracoleBundle\Model\Order\OrderShopInterface", mappedBy="section")
  48. */
  49. protected $orderShops;
  50. /**
  51. * @ORM\OneToMany(targetEntity="Lc\CaracoleBundle\Model\Product\ProductCategoryInterface", mappedBy="section")
  52. */
  53. protected $productCategories;
  54. /**
  55. * @ORM\OneToMany(targetEntity="Lc\SovBundle\Model\Site\PageInterface", mappedBy="section")
  56. */
  57. protected $pages;
  58. /**
  59. * @ORM\OneToMany(targetEntity="Lc\CaracoleBundle\Model\Setting\SectionSettingInterface", mappedBy="section", orphanRemoval=true, cascade={"persist"}, fetch="EAGER")
  60. */
  61. protected $settings;
  62. public function __construct()
  63. {
  64. $this->productFamilies = new ArrayCollection();
  65. $this->orderShops = new ArrayCollection();
  66. }
  67. public function __toString()
  68. {
  69. return $this->getTitle();
  70. }
  71. public function getMerchant(): ?MerchantInterface
  72. {
  73. return $this->merchant;
  74. }
  75. public function setMerchant(?MerchantInterface $merchant): self
  76. {
  77. $this->merchant = $merchant;
  78. return $this;
  79. }
  80. public function getColor(): ?string
  81. {
  82. return $this->color;
  83. }
  84. public function setColor(string $color): self
  85. {
  86. $this->color = $color;
  87. return $this;
  88. }
  89. public function getCycle(): ?string
  90. {
  91. return $this->cycle;
  92. }
  93. public function setCycle(string $cycle): self
  94. {
  95. $this->cycle = $cycle;
  96. return $this;
  97. }
  98. /**
  99. * @return Collection|ProductFamilyInterface[]
  100. */
  101. public function getProductFamilies(): Collection
  102. {
  103. return $this->productFamilies;
  104. }
  105. public function addProductFamily(ProductFamilyInterface $productFamily): self
  106. {
  107. if (!$this->productFamilies->contains($productFamily)) {
  108. $this->productFamilies[] = $productFamily;
  109. $productFamily->addSection($this);
  110. }
  111. return $this;
  112. }
  113. public function removeProductFamily(ProductFamilyInterface $productFamily): self
  114. {
  115. if ($this->productFamilies->contains($productFamily)) {
  116. $this->productFamilies->removeElement($productFamily);
  117. $productFamily->removeSection($this);
  118. }
  119. return $this;
  120. }
  121. /**
  122. * @return Collection|OrderShopInterface[]
  123. */
  124. public function getOrderShops(): Collection
  125. {
  126. return $this->orderShops;
  127. }
  128. public function addOrderShop(OrderShopInterface $orderShop): self
  129. {
  130. if (!$this->orderShops->contains($orderShop)) {
  131. $this->orderShops[] = $orderShop;
  132. $orderShop->setSection($this);
  133. }
  134. return $this;
  135. }
  136. public function removeOrderShop(OrderShopInterface $orderShop): self
  137. {
  138. if ($this->orderShops->contains($orderShop)) {
  139. $this->orderShops->removeElement($orderShop);
  140. // set the owning side to null (unless already changed)
  141. if ($orderShop->getSection() === $this) {
  142. $orderShop->setSection(null);
  143. }
  144. }
  145. return $this;
  146. }
  147. /**
  148. * @return Collection|ProductCategoryInterface[]
  149. */
  150. public function getProductCategories(): Collection
  151. {
  152. return $this->productCategories;
  153. }
  154. public function addProductCategory(ProductCategoryInterface $productCategory): self
  155. {
  156. if (!$this->productCategories->contains($productCategory)) {
  157. $this->productCategories[] = $productCategory;
  158. $productCategory->setSection($this);
  159. }
  160. return $this;
  161. }
  162. public function removeProductCategory(ProductCategoryInterface $productCategory): self
  163. {
  164. if ($this->productCategories->contains($productCategory)) {
  165. $this->productCategories->removeElement($productCategory);
  166. // set the owning side to null (unless already changed)
  167. if ($productCategory->getSection() === $this) {
  168. $productCategory->setSection(null);
  169. }
  170. }
  171. return $this;
  172. }
  173. /**
  174. * @return Collection|PageInterface[]
  175. */
  176. public function getPages(): Collection
  177. {
  178. return $this->pages;
  179. }
  180. public function addPage(PageInterface $page): self
  181. {
  182. if (!$this->pages->contains($page)) {
  183. $this->pages[] = $page;
  184. $page->setSection($this);
  185. }
  186. return $this;
  187. }
  188. public function removePage(PageInterface $page): self
  189. {
  190. if ($this->pages->removeElement($page)) {
  191. // set the owning side to null (unless already changed)
  192. if ($page->getSection() === $this) {
  193. $page->setSection(null);
  194. }
  195. }
  196. return $this;
  197. }
  198. public function getIsDefault(): ?bool
  199. {
  200. return $this->isDefault;
  201. }
  202. public function setIsDefault(?bool $isDefault): self
  203. {
  204. $this->isDefault = $isDefault;
  205. return $this;
  206. }
  207. /**
  208. * @return Collection|SectionSettingInterface[]
  209. */
  210. public function getSettings(): Collection
  211. {
  212. return $this->settings;
  213. }
  214. public function addSetting(SectionSettingInterface $sectionSetting): self
  215. {
  216. if (!$this->settings->contains($sectionSetting)) {
  217. $this->settings[] = $sectionSetting;
  218. $sectionSetting->setMerchant($this);
  219. }
  220. return $this;
  221. }
  222. public function removeSetting(SectionSettingInterface $sectionSetting): self
  223. {
  224. if ($this->settings->contains($sectionSetting)) {
  225. $this->settings->removeElement($sectionSetting);
  226. // set the owning side to null (unless already changed)
  227. if ($sectionSetting->getMerchant() === $this) {
  228. $sectionSetting->setMerchant(null);
  229. }
  230. }
  231. return $this;
  232. }
  233. }