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.

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