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.

SectionModel.php 11KB

3 vuotta sitten
3 vuotta sitten
3 vuotta sitten
3 vuotta sitten
3 vuotta sitten
3 vuotta sitten
3 vuotta sitten
3 vuotta sitten
3 vuotta sitten
3 vuotta sitten
3 vuotta sitten
3 vuotta sitten
3 vuotta sitten
3 vuotta sitten
3 vuotta sitten
3 vuotta sitten
3 vuotta sitten
3 vuotta sitten
3 vuotta sitten
3 vuotta sitten
3 vuotta sitten
3 vuotta sitten
3 vuotta sitten
3 vuotta sitten
3 vuotta sitten
3 vuotta sitten
3 vuotta sitten
3 vuotta sitten
3 vuotta sitten
3 vuotta sitten
3 vuotta sitten
3 vuotta sitten
3 vuotta sitten
3 vuotta sitten
3 vuotta sitten
3 vuotta sitten
3 vuotta sitten
3 vuotta sitten
3 vuotta sitten
3 vuotta sitten
3 vuotta sitten
3 vuotta sitten
3 vuotta sitten
3 vuotta sitten
3 vuotta sitten
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402
  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\OneToMany(targetEntity="Lc\CaracoleBundle\Model\Order\OrderShopInterface", mappedBy="section")
  46. */
  47. protected $orderShops;
  48. /**
  49. * @ORM\OneToMany(targetEntity="Lc\CaracoleBundle\Model\Product\ProductCategoryInterface", mappedBy="section")
  50. */
  51. protected $productCategories;
  52. /**
  53. * @ORM\OneToMany(targetEntity="Lc\SovBundle\Model\Site\NewsInterface", mappedBy="section", orphanRemoval=true)
  54. */
  55. protected $news;
  56. /**
  57. * @ORM\OneToMany(targetEntity="Lc\SovBundle\Model\Newsletter\NewsletterInterface", mappedBy="section")
  58. */
  59. protected $newsletters;
  60. /**
  61. * @ORM\OneToMany(targetEntity="Lc\SovBundle\Model\Site\PageInterface", mappedBy="section")
  62. */
  63. protected $pages;
  64. /**
  65. * @ORM\OneToMany(targetEntity="Lc\CaracoleBundle\Model\Setting\SectionSettingInterface", mappedBy="section", orphanRemoval=true, cascade={"persist"}, fetch="EAGER")
  66. */
  67. protected $settings;
  68. /**
  69. * @ORM\OneToMany(targetEntity="Lc\CaracoleBundle\Model\Section\OpeningInterface", mappedBy="section", orphanRemoval=true)
  70. */
  71. protected $openings;
  72. /**
  73. * @ORM\OneToMany(targetEntity="Lc\CaracoleBundle\Model\Product\ProductFamilySectionPropertyInterface", mappedBy="section")
  74. */
  75. protected $productFamilySectionProperties;
  76. public function __construct()
  77. {
  78. $this->orderShops = new ArrayCollection();
  79. $this->productCategories = new ArrayCollection();
  80. $this->news = new ArrayCollection();
  81. $this->newsletters = new ArrayCollection();
  82. $this->pages = new ArrayCollection();
  83. $this->settings = new ArrayCollection();
  84. $this->openings = new ArrayCollection();
  85. $this->productFamilySectionProperties = new ArrayCollection();
  86. }
  87. public function __toString()
  88. {
  89. return $this->getTitle();
  90. }
  91. public function getMerchant(): ?MerchantInterface
  92. {
  93. return $this->merchant;
  94. }
  95. public function setMerchant(?MerchantInterface $merchant): self
  96. {
  97. $this->merchant = $merchant;
  98. return $this;
  99. }
  100. public function getColor(): ?string
  101. {
  102. return $this->color;
  103. }
  104. public function setColor(string $color): self
  105. {
  106. $this->color = $color;
  107. return $this;
  108. }
  109. public function getCycleType(): ?string
  110. {
  111. return $this->cycleType;
  112. }
  113. public function setCycleType(string $cycleType): self
  114. {
  115. $this->cycleType = $cycleType;
  116. return $this;
  117. }
  118. /**
  119. * @return Collection|OrderShopInterface[]
  120. */
  121. public function getOrderShops(): Collection
  122. {
  123. return $this->orderShops;
  124. }
  125. public function addOrderShop(OrderShopInterface $orderShop): self
  126. {
  127. if (!$this->orderShops->contains($orderShop)) {
  128. $this->orderShops[] = $orderShop;
  129. $orderShop->setSection($this);
  130. }
  131. return $this;
  132. }
  133. public function removeOrderShop(OrderShopInterface $orderShop): self
  134. {
  135. if ($this->orderShops->contains($orderShop)) {
  136. $this->orderShops->removeElement($orderShop);
  137. // set the owning side to null (unless already changed)
  138. if ($orderShop->getSection() === $this) {
  139. $orderShop->setSection(null);
  140. }
  141. }
  142. return $this;
  143. }
  144. /**
  145. * @return Collection|ProductCategoryInterface[]
  146. */
  147. public function getProductCategories(): Collection
  148. {
  149. return $this->productCategories;
  150. }
  151. public function addProductCategory(ProductCategoryInterface $productCategory): self
  152. {
  153. if (!$this->productCategories->contains($productCategory)) {
  154. $this->productCategories[] = $productCategory;
  155. $productCategory->setSection($this);
  156. }
  157. return $this;
  158. }
  159. public function removeProductCategory(ProductCategoryInterface $productCategory): self
  160. {
  161. if ($this->productCategories->contains($productCategory)) {
  162. $this->productCategories->removeElement($productCategory);
  163. // set the owning side to null (unless already changed)
  164. if ($productCategory->getSection() === $this) {
  165. $productCategory->setSection(null);
  166. }
  167. }
  168. return $this;
  169. }
  170. /**
  171. * @return Collection|PageInterface[]
  172. */
  173. public function getPages(): Collection
  174. {
  175. return $this->pages;
  176. }
  177. public function addPage(PageInterface $page): self
  178. {
  179. if (!$this->pages->contains($page)) {
  180. $this->pages[] = $page;
  181. $page->setSection($this);
  182. }
  183. return $this;
  184. }
  185. public function removePage(PageInterface $page): self
  186. {
  187. if ($this->pages->removeElement($page)) {
  188. // set the owning side to null (unless already changed)
  189. if ($page->getSection() === $this) {
  190. $page->setSection(null);
  191. }
  192. }
  193. return $this;
  194. }
  195. /**
  196. * @return Collection|NewsInterface[]
  197. */
  198. public function getNews(): Collection
  199. {
  200. return $this->news;
  201. }
  202. public function addNews(NewsInterface $news): self
  203. {
  204. if (!$this->news->contains($news)) {
  205. $this->news[] = $news;
  206. $news->setSection($this);
  207. }
  208. return $this;
  209. }
  210. public function removeNews(NewsInterface $news): self
  211. {
  212. if ($this->news->contains($news)) {
  213. $this->news->removeElement($news);
  214. // set the owning side to null (unless already changed)
  215. if ($news->getSection() === $this) {
  216. $news->setSection(null);
  217. }
  218. }
  219. return $this;
  220. }
  221. /**
  222. * @return Collection|NewsletterInterface[]
  223. */
  224. public function getNewsletters(): Collection
  225. {
  226. return $this->newsletters;
  227. }
  228. public function addNewsletter(NewsletterInterface $newsletter): self
  229. {
  230. if (!$this->newsletters->contains($newsletter)) {
  231. $this->newsletters[] = $newsletter;
  232. $newsletter->setSection($this);
  233. }
  234. return $this;
  235. }
  236. public function removeNewsletter(NewsletterInterface $newsletter): self
  237. {
  238. if ($this->newsletters->contains($newsletter)) {
  239. $this->newsletters->removeElement($newsletter);
  240. // set the owning side to null (unless already changed)
  241. if ($newsletter->getSection() === $this) {
  242. $newsletter->setSection(null);
  243. }
  244. }
  245. return $this;
  246. }
  247. public function getIsDefault(): ?bool
  248. {
  249. return $this->isDefault;
  250. }
  251. public function setIsDefault(?bool $isDefault): self
  252. {
  253. $this->isDefault = $isDefault;
  254. return $this;
  255. }
  256. /**
  257. * @return Collection|SectionSettingInterface[]
  258. */
  259. public function getSettings(): Collection
  260. {
  261. return $this->settings;
  262. }
  263. public function addSetting(SectionSettingInterface $sectionSetting): self
  264. {
  265. if (!$this->settings->contains($sectionSetting)) {
  266. $this->settings[] = $sectionSetting;
  267. $sectionSetting->setSection($this);
  268. }
  269. return $this;
  270. }
  271. public function removeSetting(SectionSettingInterface $sectionSetting): self
  272. {
  273. if ($this->settings->contains($sectionSetting)) {
  274. $this->settings->removeElement($sectionSetting);
  275. // set the owning side to null (unless already changed)
  276. if ($sectionSetting->getSection() === $this) {
  277. $sectionSetting->setSection(null);
  278. }
  279. }
  280. return $this;
  281. }
  282. /**
  283. * @return Collection|OpeningInterface[]
  284. */
  285. public function getOpenings(): Collection
  286. {
  287. return $this->openings;
  288. }
  289. public function addOpening(OpeningInterface $opening): self
  290. {
  291. if (!$this->openings->contains($opening)) {
  292. $this->openings[] = $opening;
  293. $opening->setSection($this);
  294. }
  295. return $this;
  296. }
  297. public function removeOpening(OpeningInterface $opening): self
  298. {
  299. if ($this->openings->removeElement($opening)) {
  300. // set the owning side to null (unless already changed)
  301. if ($opening->getSection() === $this) {
  302. $opening->setSection(null);
  303. }
  304. }
  305. return $this;
  306. }
  307. /**
  308. * @return Collection|ProductFamilySectionPropertyInterface[]
  309. */
  310. public function getProductFamilySectionProperties(): Collection
  311. {
  312. return $this->productFamilySectionProperties;
  313. }
  314. public function addProductFamilySectionProperty(ProductFamilySectionPropertyInterface $productFamilySectionProperty): self
  315. {
  316. if (!$this->productFamilySectionProperties->contains($productFamilySectionProperty)) {
  317. $this->productFamilySectionProperties[] = $productFamilySectionProperty;
  318. $productFamilySectionProperty->setSection($this);
  319. }
  320. return $this;
  321. }
  322. public function removeProductFamilySectionProperty(ProductFamilySectionPropertyInterface $productFamilySectionProperty): self
  323. {
  324. if ($this->productFamilySectionProperties->removeElement($productFamilySectionProperty)) {
  325. // set the owning side to null (unless already changed)
  326. if ($productFamilySectionProperty->getSection() === $this) {
  327. $productFamilySectionProperty->setSection(null);
  328. }
  329. }
  330. return $this;
  331. }
  332. }