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

409 行
11KB

  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\Product\ProductCategoryInterface;
  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, SectionInterface
  21. {
  22. const DEVALIAS_COMMON = 'common';
  23. /**
  24. * @ORM\Column(type="string", length=255)
  25. * @Gedmo\Slug(fields={"title"}, unique=false)
  26. */
  27. protected $slug;
  28. /**
  29. * @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Merchant\MerchantInterface", inversedBy="sections")
  30. * @ORM\JoinColumn(nullable=false)
  31. */
  32. protected $merchant;
  33. /**
  34. * @ORM\Column(type="string", length=32)
  35. */
  36. protected $cycleType;
  37. const CYCLE_TYPE_DAY = 'day';
  38. const CYCLE_TYPE_WEEK = 'week';
  39. const CYCLE_TYPE_MONTH = 'month';
  40. const CYCLE_TYPE_YEAR = 'year';
  41. /**
  42. * @ORM\Column(type="boolean", nullable=true)
  43. */
  44. protected $isDefault;
  45. /**
  46. * @ORM\Column(type="string", length=32)
  47. */
  48. protected $color;
  49. /**
  50. * @ORM\OneToMany(targetEntity="Lc\CaracoleBundle\Model\Order\OrderShopInterface", mappedBy="section")
  51. */
  52. protected $orderShops;
  53. /**
  54. * @ORM\OneToMany(targetEntity="Lc\CaracoleBundle\Model\Product\ProductCategoryInterface", mappedBy="section")
  55. */
  56. protected $productCategories;
  57. /**
  58. * @ORM\OneToMany(targetEntity="Lc\SovBundle\Model\Site\NewsInterface", mappedBy="section", orphanRemoval=true)
  59. */
  60. protected $news;
  61. /**
  62. * @ORM\OneToMany(targetEntity="Lc\SovBundle\Model\Newsletter\NewsletterInterface", mappedBy="section")
  63. */
  64. protected $newsletters;
  65. /**
  66. * @ORM\OneToMany(targetEntity="Lc\SovBundle\Model\Site\PageInterface", mappedBy="section")
  67. */
  68. protected $pages;
  69. /**
  70. * @ORM\OneToMany(targetEntity="Lc\CaracoleBundle\Model\Setting\SectionSettingInterface", mappedBy="section", orphanRemoval=true, cascade={"persist"}, fetch="EAGER")
  71. */
  72. protected $settings;
  73. /**
  74. * @ORM\OneToMany(targetEntity="Lc\CaracoleBundle\Model\Section\OpeningInterface", mappedBy="section", orphanRemoval=true)
  75. */
  76. protected $openings;
  77. /**
  78. * @ORM\OneToMany(targetEntity="Lc\CaracoleBundle\Model\Product\ProductFamilySectionPropertyInterface", mappedBy="section")
  79. */
  80. protected $productFamilySectionProperties;
  81. public function __construct()
  82. {
  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|OrderShopInterface[]
  125. */
  126. public function getOrderShops(): Collection
  127. {
  128. return $this->orderShops;
  129. }
  130. public function addOrderShop(OrderShopInterface $orderShop): self
  131. {
  132. if (!$this->orderShops->contains($orderShop)) {
  133. $this->orderShops[] = $orderShop;
  134. $orderShop->setSection($this);
  135. }
  136. return $this;
  137. }
  138. public function removeOrderShop(OrderShopInterface $orderShop): self
  139. {
  140. if ($this->orderShops->contains($orderShop)) {
  141. $this->orderShops->removeElement($orderShop);
  142. // set the owning side to null (unless already changed)
  143. if ($orderShop->getSection() === $this) {
  144. $orderShop->setSection(null);
  145. }
  146. }
  147. return $this;
  148. }
  149. /**
  150. * @return Collection|ProductCategoryInterface[]
  151. */
  152. public function getProductCategories(): Collection
  153. {
  154. return $this->productCategories;
  155. }
  156. public function addProductCategory(ProductCategoryInterface $productCategory): self
  157. {
  158. if (!$this->productCategories->contains($productCategory)) {
  159. $this->productCategories[] = $productCategory;
  160. $productCategory->setSection($this);
  161. }
  162. return $this;
  163. }
  164. public function removeProductCategory(ProductCategoryInterface $productCategory): self
  165. {
  166. if ($this->productCategories->contains($productCategory)) {
  167. $this->productCategories->removeElement($productCategory);
  168. // set the owning side to null (unless already changed)
  169. if ($productCategory->getSection() === $this) {
  170. $productCategory->setSection(null);
  171. }
  172. }
  173. return $this;
  174. }
  175. /**
  176. * @return Collection|PageInterface[]
  177. */
  178. public function getPages(): Collection
  179. {
  180. return $this->pages;
  181. }
  182. public function addPage(PageInterface $page): self
  183. {
  184. if (!$this->pages->contains($page)) {
  185. $this->pages[] = $page;
  186. $page->setSection($this);
  187. }
  188. return $this;
  189. }
  190. public function removePage(PageInterface $page): self
  191. {
  192. if ($this->pages->removeElement($page)) {
  193. // set the owning side to null (unless already changed)
  194. if ($page->getSection() === $this) {
  195. $page->setSection(null);
  196. }
  197. }
  198. return $this;
  199. }
  200. /**
  201. * @return Collection|NewsInterface[]
  202. */
  203. public function getNews(): Collection
  204. {
  205. return $this->news;
  206. }
  207. public function addNews(NewsInterface $news): self
  208. {
  209. if (!$this->news->contains($news)) {
  210. $this->news[] = $news;
  211. $news->setSection($this);
  212. }
  213. return $this;
  214. }
  215. public function removeNews(NewsInterface $news): self
  216. {
  217. if ($this->news->contains($news)) {
  218. $this->news->removeElement($news);
  219. // set the owning side to null (unless already changed)
  220. if ($news->getSection() === $this) {
  221. $news->setSection(null);
  222. }
  223. }
  224. return $this;
  225. }
  226. /**
  227. * @return Collection|NewsletterInterface[]
  228. */
  229. public function getNewsletters(): Collection
  230. {
  231. return $this->newsletters;
  232. }
  233. public function addNewsletter(NewsletterInterface $newsletter): self
  234. {
  235. if (!$this->newsletters->contains($newsletter)) {
  236. $this->newsletters[] = $newsletter;
  237. $newsletter->setSection($this);
  238. }
  239. return $this;
  240. }
  241. public function removeNewsletter(NewsletterInterface $newsletter): self
  242. {
  243. if ($this->newsletters->contains($newsletter)) {
  244. $this->newsletters->removeElement($newsletter);
  245. // set the owning side to null (unless already changed)
  246. if ($newsletter->getSection() === $this) {
  247. $newsletter->setSection(null);
  248. }
  249. }
  250. return $this;
  251. }
  252. public function getIsDefault(): ?bool
  253. {
  254. return $this->isDefault;
  255. }
  256. public function setIsDefault(?bool $isDefault): self
  257. {
  258. $this->isDefault = $isDefault;
  259. return $this;
  260. }
  261. /**
  262. * @return Collection|SectionSettingInterface[]
  263. */
  264. public function getSettings(): Collection
  265. {
  266. return $this->settings;
  267. }
  268. public function addSetting(SectionSettingInterface $sectionSetting): self
  269. {
  270. if (!$this->settings->contains($sectionSetting)) {
  271. $this->settings[] = $sectionSetting;
  272. $sectionSetting->setSection($this);
  273. }
  274. return $this;
  275. }
  276. public function removeSetting(SectionSettingInterface $sectionSetting): self
  277. {
  278. if ($this->settings->contains($sectionSetting)) {
  279. $this->settings->removeElement($sectionSetting);
  280. // set the owning side to null (unless already changed)
  281. if ($sectionSetting->getSection() === $this) {
  282. $sectionSetting->setSection(null);
  283. }
  284. }
  285. return $this;
  286. }
  287. /**
  288. * @return Collection|OpeningInterface[]
  289. */
  290. public function getOpenings(): Collection
  291. {
  292. return $this->openings;
  293. }
  294. public function addOpening(OpeningInterface $opening): self
  295. {
  296. if (!$this->openings->contains($opening)) {
  297. $this->openings[] = $opening;
  298. $opening->setSection($this);
  299. }
  300. return $this;
  301. }
  302. public function removeOpening(OpeningInterface $opening): self
  303. {
  304. if ($this->openings->removeElement($opening)) {
  305. // set the owning side to null (unless already changed)
  306. if ($opening->getSection() === $this) {
  307. $opening->setSection(null);
  308. }
  309. }
  310. return $this;
  311. }
  312. /**
  313. * @return Collection|ProductFamilySectionPropertyInterface[]
  314. */
  315. public function getProductFamilySectionProperties(): Collection
  316. {
  317. return $this->productFamilySectionProperties;
  318. }
  319. public function addProductFamilySectionProperty(ProductFamilySectionPropertyInterface $productFamilySectionProperty): self
  320. {
  321. if (!$this->productFamilySectionProperties->contains($productFamilySectionProperty)) {
  322. $this->productFamilySectionProperties[] = $productFamilySectionProperty;
  323. $productFamilySectionProperty->setSection($this);
  324. }
  325. return $this;
  326. }
  327. public function removeProductFamilySectionProperty(ProductFamilySectionPropertyInterface $productFamilySectionProperty): self
  328. {
  329. if ($this->productFamilySectionProperties->removeElement($productFamilySectionProperty)) {
  330. // set the owning side to null (unless already changed)
  331. if ($productFamilySectionProperty->getSection() === $this) {
  332. $productFamilySectionProperty->setSection(null);
  333. }
  334. }
  335. return $this;
  336. }
  337. }