選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

445 行
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. 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. }