Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

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 лет назад
3 лет назад
3 лет назад
3 лет назад
3 лет назад
3 лет назад
3 лет назад
3 лет назад
3 лет назад
3 лет назад
3 лет назад
3 лет назад
3 лет назад
3 лет назад
3 лет назад
3 лет назад
3 лет назад
3 лет назад
3 лет назад
3 лет назад
3 лет назад
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444
  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. public function __construct()
  87. {
  88. $this->orderShops = new ArrayCollection();
  89. $this->productCategories = new ArrayCollection();
  90. $this->news = new ArrayCollection();
  91. $this->newsletters = new ArrayCollection();
  92. $this->pages = new ArrayCollection();
  93. $this->settings = new ArrayCollection();
  94. $this->openings = new ArrayCollection();
  95. $this->productFamilySectionProperties = new ArrayCollection();
  96. }
  97. public function __toString()
  98. {
  99. return $this->getTitle();
  100. }
  101. public function getMerchant(): ?MerchantInterface
  102. {
  103. return $this->merchant;
  104. }
  105. public function setMerchant(?MerchantInterface $merchant): self
  106. {
  107. $this->merchant = $merchant;
  108. return $this;
  109. }
  110. public function getColor(): ?string
  111. {
  112. return $this->color;
  113. }
  114. public function setColor(string $color): self
  115. {
  116. $this->color = $color;
  117. return $this;
  118. }
  119. public function getCycleType(): ?string
  120. {
  121. return $this->cycleType;
  122. }
  123. public function setCycleType(string $cycleType): self
  124. {
  125. $this->cycleType = $cycleType;
  126. return $this;
  127. }
  128. /**
  129. * @return Collection|OrderShopInterface[]
  130. */
  131. public function getOrderShops(): Collection
  132. {
  133. return $this->orderShops;
  134. }
  135. public function addOrderShop(OrderShopInterface $orderShop): self
  136. {
  137. if (!$this->orderShops->contains($orderShop)) {
  138. $this->orderShops[] = $orderShop;
  139. $orderShop->setSection($this);
  140. }
  141. return $this;
  142. }
  143. public function removeOrderShop(OrderShopInterface $orderShop): self
  144. {
  145. if ($this->orderShops->contains($orderShop)) {
  146. $this->orderShops->removeElement($orderShop);
  147. // set the owning side to null (unless already changed)
  148. if ($orderShop->getSection() === $this) {
  149. $orderShop->setSection(null);
  150. }
  151. }
  152. return $this;
  153. }
  154. /**
  155. * @return Collection|ProductCategoryInterface[]
  156. */
  157. public function getProductCategories(): Collection
  158. {
  159. return $this->productCategories;
  160. }
  161. public function addProductCategory(ProductCategoryInterface $productCategory): self
  162. {
  163. if (!$this->productCategories->contains($productCategory)) {
  164. $this->productCategories[] = $productCategory;
  165. $productCategory->setSection($this);
  166. }
  167. return $this;
  168. }
  169. public function removeProductCategory(ProductCategoryInterface $productCategory): self
  170. {
  171. if ($this->productCategories->contains($productCategory)) {
  172. $this->productCategories->removeElement($productCategory);
  173. // set the owning side to null (unless already changed)
  174. if ($productCategory->getSection() === $this) {
  175. $productCategory->setSection(null);
  176. }
  177. }
  178. return $this;
  179. }
  180. /**
  181. * @return Collection|PageInterface[]
  182. */
  183. public function getPages(): Collection
  184. {
  185. return $this->pages;
  186. }
  187. public function addPage(PageInterface $page): self
  188. {
  189. if (!$this->pages->contains($page)) {
  190. $this->pages[] = $page;
  191. $page->setSection($this);
  192. }
  193. return $this;
  194. }
  195. public function removePage(PageInterface $page): self
  196. {
  197. if ($this->pages->removeElement($page)) {
  198. // set the owning side to null (unless already changed)
  199. if ($page->getSection() === $this) {
  200. $page->setSection(null);
  201. }
  202. }
  203. return $this;
  204. }
  205. /**
  206. * @return Collection|NewsInterface[]
  207. */
  208. public function getNews(): Collection
  209. {
  210. return $this->news;
  211. }
  212. public function addNews(NewsInterface $news): self
  213. {
  214. if (!$this->news->contains($news)) {
  215. $this->news[] = $news;
  216. $news->setSection($this);
  217. }
  218. return $this;
  219. }
  220. public function removeNews(NewsInterface $news): self
  221. {
  222. if ($this->news->contains($news)) {
  223. $this->news->removeElement($news);
  224. // set the owning side to null (unless already changed)
  225. if ($news->getSection() === $this) {
  226. $news->setSection(null);
  227. }
  228. }
  229. return $this;
  230. }
  231. /**
  232. * @return Collection|NewsletterInterface[]
  233. */
  234. public function getNewsletters(): Collection
  235. {
  236. return $this->newsletters;
  237. }
  238. public function addNewsletter(NewsletterInterface $newsletter): self
  239. {
  240. if (!$this->newsletters->contains($newsletter)) {
  241. $this->newsletters[] = $newsletter;
  242. $newsletter->setSection($this);
  243. }
  244. return $this;
  245. }
  246. public function removeNewsletter(NewsletterInterface $newsletter): self
  247. {
  248. if ($this->newsletters->contains($newsletter)) {
  249. $this->newsletters->removeElement($newsletter);
  250. // set the owning side to null (unless already changed)
  251. if ($newsletter->getSection() === $this) {
  252. $newsletter->setSection(null);
  253. }
  254. }
  255. return $this;
  256. }
  257. public function getIsDefault(): ?bool
  258. {
  259. return $this->isDefault;
  260. }
  261. public function setIsDefault(?bool $isDefault): self
  262. {
  263. $this->isDefault = $isDefault;
  264. return $this;
  265. }
  266. /**
  267. * @return Collection|SectionSettingInterface[]
  268. */
  269. public function getSettings(): Collection
  270. {
  271. return $this->settings;
  272. }
  273. public function addSetting(SectionSettingInterface $sectionSetting): self
  274. {
  275. if (!$this->settings->contains($sectionSetting)) {
  276. $this->settings[] = $sectionSetting;
  277. $sectionSetting->setSection($this);
  278. }
  279. return $this;
  280. }
  281. public function removeSetting(SectionSettingInterface $sectionSetting): self
  282. {
  283. if ($this->settings->contains($sectionSetting)) {
  284. $this->settings->removeElement($sectionSetting);
  285. // set the owning side to null (unless already changed)
  286. if ($sectionSetting->getSection() === $this) {
  287. $sectionSetting->setSection(null);
  288. }
  289. }
  290. return $this;
  291. }
  292. /**
  293. * @return Collection|OpeningInterface[]
  294. */
  295. public function getOpenings(): Collection
  296. {
  297. return $this->openings;
  298. }
  299. public function addOpening(OpeningInterface $opening): self
  300. {
  301. if (!$this->openings->contains($opening)) {
  302. $this->openings[] = $opening;
  303. $opening->setSection($this);
  304. }
  305. return $this;
  306. }
  307. public function removeOpening(OpeningInterface $opening): self
  308. {
  309. if ($this->openings->removeElement($opening)) {
  310. // set the owning side to null (unless already changed)
  311. if ($opening->getSection() === $this) {
  312. $opening->setSection(null);
  313. }
  314. }
  315. return $this;
  316. }
  317. /**
  318. * @return Collection|ProductFamilySectionPropertyInterface[]
  319. */
  320. public function getProductFamilySectionProperties(): Collection
  321. {
  322. return $this->productFamilySectionProperties;
  323. }
  324. public function addProductFamilySectionProperty(ProductFamilySectionPropertyInterface $productFamilySectionProperty): self
  325. {
  326. if (!$this->productFamilySectionProperties->contains($productFamilySectionProperty)) {
  327. $this->productFamilySectionProperties[] = $productFamilySectionProperty;
  328. $productFamilySectionProperty->setSection($this);
  329. }
  330. return $this;
  331. }
  332. public function removeProductFamilySectionProperty(ProductFamilySectionPropertyInterface $productFamilySectionProperty): self
  333. {
  334. if ($this->productFamilySectionProperties->removeElement($productFamilySectionProperty)) {
  335. // set the owning side to null (unless already changed)
  336. if ($productFamilySectionProperty->getSection() === $this) {
  337. $productFamilySectionProperty->setSection(null);
  338. }
  339. }
  340. return $this;
  341. }
  342. /**
  343. * @return Collection|PointSaleSectionInterface[]
  344. */
  345. public function getPointSaleSections(): Collection
  346. {
  347. return $this->pointSaleSections;
  348. }
  349. public function addPointSaleSection(PointSaleSectionInterface $pointSaleSection): self
  350. {
  351. if (!$this->pointSaleSections->contains($pointSaleSection)) {
  352. $this->pointSaleSections[] = $pointSaleSection;
  353. $pointSaleSection->setSection($this);
  354. }
  355. return $this;
  356. }
  357. public function removePointSaleSection(PointSaleSectionInterface $pointSaleSection): self
  358. {
  359. if ($this->pointSaleSections->removeElement($pointSaleSection)) {
  360. // set the owning side to null (unless already changed)
  361. if ($pointSaleSection->getSection() === $this) {
  362. $pointSaleSection->setSection(null);
  363. }
  364. }
  365. return $this;
  366. }
  367. }