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.

462 line
12KB

  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 Gedmo\Mapping\Annotation as Gedmo;
  7. use Lc\CaracoleBundle\Doctrine\Extension\FilterMerchantInterface;
  8. use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
  9. use Lc\CaracoleBundle\Model\Order\OrderShopInterface;
  10. use Lc\CaracoleBundle\Model\PointSale\PointSaleSectionInterface;
  11. use Lc\CaracoleBundle\Model\Product\ProductCategoryInterface;
  12. use Lc\CaracoleBundle\Model\Product\ProductFamilySectionPropertyInterface;
  13. use Lc\CaracoleBundle\Model\Setting\SectionSettingInterface;
  14. use Lc\SovBundle\Model\Newsletter\NewsletterInterface;
  15. use Lc\SovBundle\Model\Site\NewsInterface;
  16. use Lc\SovBundle\Model\Site\PageInterface;
  17. use Lc\SovBundle\Doctrine\Pattern\AbstractFullEntity;
  18. /**
  19. * @ORM\MappedSuperclass()
  20. */
  21. abstract class SectionModel extends AbstractFullEntity implements FilterMerchantInterface, SectionInterface
  22. {
  23. const DEVALIAS_COMMON = 'common';
  24. /**
  25. * @ORM\Column(type="string", length=255)
  26. * @Gedmo\Slug(fields={"title"}, unique=false)
  27. */
  28. protected $slug;
  29. /**
  30. * @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Merchant\MerchantInterface", inversedBy="sections")
  31. * @ORM\JoinColumn(nullable=false)
  32. */
  33. protected $merchant;
  34. /**
  35. * @ORM\Column(type="string", length=32)
  36. */
  37. protected $cycleType;
  38. const CYCLE_TYPE_DAY = 'day';
  39. const CYCLE_TYPE_WEEK = 'week';
  40. const CYCLE_TYPE_MONTH = 'month';
  41. const CYCLE_TYPE_YEAR = 'year';
  42. /**
  43. * @ORM\Column(type="boolean", nullable=true)
  44. */
  45. protected $isDefault;
  46. /**
  47. * @ORM\Column(type="string", length=32)
  48. */
  49. protected $color;
  50. /**
  51. * @ORM\OneToMany(targetEntity="Lc\CaracoleBundle\Model\Order\OrderShopInterface", mappedBy="section")
  52. */
  53. protected $orderShops;
  54. /**
  55. * @ORM\OneToMany(targetEntity="Lc\CaracoleBundle\Model\Product\ProductCategoryInterface", mappedBy="section")
  56. */
  57. protected $productCategories;
  58. /**
  59. * @ORM\OneToMany(targetEntity="Lc\SovBundle\Model\Site\NewsInterface", mappedBy="section", orphanRemoval=true)
  60. */
  61. protected $news;
  62. /**
  63. * @ORM\OneToMany(targetEntity="Lc\SovBundle\Model\Newsletter\NewsletterInterface", mappedBy="section")
  64. */
  65. protected $newsletters;
  66. /**
  67. * @ORM\OneToMany(targetEntity="Lc\SovBundle\Model\Site\PageInterface", mappedBy="section")
  68. */
  69. protected $pages;
  70. /**
  71. * @ORM\OneToMany(targetEntity="Lc\CaracoleBundle\Model\Setting\SectionSettingInterface", mappedBy="section", orphanRemoval=true, cascade={"persist"}, fetch="EAGER")
  72. */
  73. protected $settings;
  74. /**
  75. * @ORM\OneToMany(targetEntity="Lc\CaracoleBundle\Model\Section\OpeningInterface", mappedBy="section", orphanRemoval=true)
  76. */
  77. protected $openings;
  78. /**
  79. * @ORM\OneToMany(targetEntity="Lc\CaracoleBundle\Model\Product\ProductFamilySectionPropertyInterface", mappedBy="section")
  80. */
  81. protected $productFamilySectionProperties;
  82. /**
  83. * @ORM\OneToMany(targetEntity="Lc\CaracoleBundle\Model\PointSale\PointSaleSectionInterface", mappedBy="section")
  84. */
  85. protected $pointSaleSections;
  86. /**
  87. * @ORM\Column(type="boolean", nullable=true)
  88. */
  89. protected $isOnlineFrontend;
  90. public function __construct()
  91. {
  92. $this->orderShops = new ArrayCollection();
  93. $this->productCategories = new ArrayCollection();
  94. $this->news = new ArrayCollection();
  95. $this->newsletters = new ArrayCollection();
  96. $this->pages = new ArrayCollection();
  97. $this->settings = new ArrayCollection();
  98. $this->openings = new ArrayCollection();
  99. $this->productFamilySectionProperties = new ArrayCollection();
  100. }
  101. public function __toString()
  102. {
  103. return $this->getTitle();
  104. }
  105. public function getMerchant(): ?MerchantInterface
  106. {
  107. return $this->merchant;
  108. }
  109. public function setMerchant(?MerchantInterface $merchant): self
  110. {
  111. $this->merchant = $merchant;
  112. return $this;
  113. }
  114. public function getColor(): ?string
  115. {
  116. return $this->color;
  117. }
  118. public function setColor(string $color): self
  119. {
  120. $this->color = $color;
  121. return $this;
  122. }
  123. public function getCycleType(): ?string
  124. {
  125. return $this->cycleType;
  126. }
  127. public function setCycleType(string $cycleType): self
  128. {
  129. $this->cycleType = $cycleType;
  130. return $this;
  131. }
  132. /**
  133. * @return Collection|OrderShopInterface[]
  134. */
  135. public function getOrderShops(): Collection
  136. {
  137. return $this->orderShops;
  138. }
  139. public function addOrderShop(OrderShopInterface $orderShop): self
  140. {
  141. if (!$this->orderShops->contains($orderShop)) {
  142. $this->orderShops[] = $orderShop;
  143. $orderShop->setSection($this);
  144. }
  145. return $this;
  146. }
  147. public function removeOrderShop(OrderShopInterface $orderShop): self
  148. {
  149. if ($this->orderShops->contains($orderShop)) {
  150. $this->orderShops->removeElement($orderShop);
  151. // set the owning side to null (unless already changed)
  152. if ($orderShop->getSection() === $this) {
  153. $orderShop->setSection(null);
  154. }
  155. }
  156. return $this;
  157. }
  158. /**
  159. * @return Collection|ProductCategoryInterface[]
  160. */
  161. public function getProductCategories(): Collection
  162. {
  163. return $this->productCategories;
  164. }
  165. public function addProductCategory(ProductCategoryInterface $productCategory): self
  166. {
  167. if (!$this->productCategories->contains($productCategory)) {
  168. $this->productCategories[] = $productCategory;
  169. $productCategory->setSection($this);
  170. }
  171. return $this;
  172. }
  173. public function removeProductCategory(ProductCategoryInterface $productCategory): self
  174. {
  175. if ($this->productCategories->contains($productCategory)) {
  176. $this->productCategories->removeElement($productCategory);
  177. // set the owning side to null (unless already changed)
  178. if ($productCategory->getSection() === $this) {
  179. $productCategory->setSection(null);
  180. }
  181. }
  182. return $this;
  183. }
  184. /**
  185. * @return Collection|PageInterface[]
  186. */
  187. public function getPages(): Collection
  188. {
  189. return $this->pages;
  190. }
  191. public function addPage(PageInterface $page): self
  192. {
  193. if (!$this->pages->contains($page)) {
  194. $this->pages[] = $page;
  195. $page->setSection($this);
  196. }
  197. return $this;
  198. }
  199. public function removePage(PageInterface $page): self
  200. {
  201. if ($this->pages->removeElement($page)) {
  202. // set the owning side to null (unless already changed)
  203. if ($page->getSection() === $this) {
  204. $page->setSection(null);
  205. }
  206. }
  207. return $this;
  208. }
  209. /**
  210. * @return Collection|NewsInterface[]
  211. */
  212. public function getNews(): Collection
  213. {
  214. return $this->news;
  215. }
  216. public function addNews(NewsInterface $news): self
  217. {
  218. if (!$this->news->contains($news)) {
  219. $this->news[] = $news;
  220. $news->setSection($this);
  221. }
  222. return $this;
  223. }
  224. public function removeNews(NewsInterface $news): self
  225. {
  226. if ($this->news->contains($news)) {
  227. $this->news->removeElement($news);
  228. // set the owning side to null (unless already changed)
  229. if ($news->getSection() === $this) {
  230. $news->setSection(null);
  231. }
  232. }
  233. return $this;
  234. }
  235. /**
  236. * @return Collection|NewsletterInterface[]
  237. */
  238. public function getNewsletters(): Collection
  239. {
  240. return $this->newsletters;
  241. }
  242. public function addNewsletter(NewsletterInterface $newsletter): self
  243. {
  244. if (!$this->newsletters->contains($newsletter)) {
  245. $this->newsletters[] = $newsletter;
  246. $newsletter->setSection($this);
  247. }
  248. return $this;
  249. }
  250. public function removeNewsletter(NewsletterInterface $newsletter): self
  251. {
  252. if ($this->newsletters->contains($newsletter)) {
  253. $this->newsletters->removeElement($newsletter);
  254. // set the owning side to null (unless already changed)
  255. if ($newsletter->getSection() === $this) {
  256. $newsletter->setSection(null);
  257. }
  258. }
  259. return $this;
  260. }
  261. public function getIsDefault(): ?bool
  262. {
  263. return $this->isDefault;
  264. }
  265. public function setIsDefault(?bool $isDefault): self
  266. {
  267. $this->isDefault = $isDefault;
  268. return $this;
  269. }
  270. /**
  271. * @return Collection|SectionSettingInterface[]
  272. */
  273. public function getSettings(): Collection
  274. {
  275. return $this->settings;
  276. }
  277. public function addSetting(SectionSettingInterface $sectionSetting): self
  278. {
  279. if (!$this->settings->contains($sectionSetting)) {
  280. $this->settings[] = $sectionSetting;
  281. $sectionSetting->setSection($this);
  282. }
  283. return $this;
  284. }
  285. public function removeSetting(SectionSettingInterface $sectionSetting): self
  286. {
  287. if ($this->settings->contains($sectionSetting)) {
  288. $this->settings->removeElement($sectionSetting);
  289. // set the owning side to null (unless already changed)
  290. if ($sectionSetting->getSection() === $this) {
  291. $sectionSetting->setSection(null);
  292. }
  293. }
  294. return $this;
  295. }
  296. /**
  297. * @return Collection|OpeningInterface[]
  298. */
  299. public function getOpenings(): Collection
  300. {
  301. return $this->openings;
  302. }
  303. public function addOpening(OpeningInterface $opening): self
  304. {
  305. if (!$this->openings->contains($opening)) {
  306. $this->openings[] = $opening;
  307. $opening->setSection($this);
  308. }
  309. return $this;
  310. }
  311. public function removeOpening(OpeningInterface $opening): self
  312. {
  313. if ($this->openings->removeElement($opening)) {
  314. // set the owning side to null (unless already changed)
  315. if ($opening->getSection() === $this) {
  316. $opening->setSection(null);
  317. }
  318. }
  319. return $this;
  320. }
  321. /**
  322. * @return Collection|ProductFamilySectionPropertyInterface[]
  323. */
  324. public function getProductFamilySectionProperties(): Collection
  325. {
  326. return $this->productFamilySectionProperties;
  327. }
  328. public function addProductFamilySectionProperty(ProductFamilySectionPropertyInterface $productFamilySectionProperty): self
  329. {
  330. if (!$this->productFamilySectionProperties->contains($productFamilySectionProperty)) {
  331. $this->productFamilySectionProperties[] = $productFamilySectionProperty;
  332. $productFamilySectionProperty->setSection($this);
  333. }
  334. return $this;
  335. }
  336. public function removeProductFamilySectionProperty(ProductFamilySectionPropertyInterface $productFamilySectionProperty): self
  337. {
  338. if ($this->productFamilySectionProperties->removeElement($productFamilySectionProperty)) {
  339. // set the owning side to null (unless already changed)
  340. if ($productFamilySectionProperty->getSection() === $this) {
  341. $productFamilySectionProperty->setSection(null);
  342. }
  343. }
  344. return $this;
  345. }
  346. /**
  347. * @return Collection|PointSaleSectionInterface[]
  348. */
  349. public function getPointSaleSections(): Collection
  350. {
  351. return $this->pointSaleSections;
  352. }
  353. public function addPointSaleSection(PointSaleSectionInterface $pointSaleSection): self
  354. {
  355. if (!$this->pointSaleSections->contains($pointSaleSection)) {
  356. $this->pointSaleSections[] = $pointSaleSection;
  357. $pointSaleSection->setSection($this);
  358. }
  359. return $this;
  360. }
  361. public function removePointSaleSection(PointSaleSectionInterface $pointSaleSection): self
  362. {
  363. if ($this->pointSaleSections->removeElement($pointSaleSection)) {
  364. // set the owning side to null (unless already changed)
  365. if ($pointSaleSection->getSection() === $this) {
  366. $pointSaleSection->setSection(null);
  367. }
  368. }
  369. return $this;
  370. }
  371. public function getIsOnlineFrontend(): ?bool
  372. {
  373. return $this->isOnlineFrontend;
  374. }
  375. public function setIsOnlineFrontend(?bool $isOnlineFrontend): self
  376. {
  377. $this->isOnlineFrontend = $isOnlineFrontend;
  378. return $this;
  379. }
  380. }