|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397 |
- <?php
-
- namespace Lc\CaracoleBundle\Model\Section;
-
- use Doctrine\Common\Collections\ArrayCollection;
- use Doctrine\Common\Collections\Collection;
- use Doctrine\ORM\Mapping as ORM;
- use Lc\CaracoleBundle\Doctrine\Extension\FilterMerchantInterface;
- use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
- use Lc\CaracoleBundle\Model\Order\OrderShopInterface;
- use Lc\CaracoleBundle\Model\Product\ProductCategoryInterface;
- use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface;
- use Lc\CaracoleBundle\Model\Setting\SectionSettingInterface;
- use Lc\SovBundle\Model\Newsletter\NewsletterInterface;
- use Lc\SovBundle\Model\Site\NewsInterface;
- use Lc\SovBundle\Model\Site\PageInterface;
- use Lc\SovBundle\Doctrine\Pattern\AbstractFullEntity;
-
- /**
- * @ORM\MappedSuperclass()
- */
- abstract class SectionModel extends AbstractFullEntity implements FilterMerchantInterface
- {
- /**
- * @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Merchant\MerchantInterface", inversedBy="sections")
- * @ORM\JoinColumn(nullable=false)
- */
- protected $merchant;
-
- /**
- * @ORM\Column(type="string", length=32)
- */
- protected $cycleType;
-
- const CYCLE_TYPE_DAY = 'day';
- const CYCLE_TYPE_WEEK = 'week';
- const CYCLE_TYPE_MONTH = 'month';
- const CYCLE_TYPE_YEAR = 'year';
-
- /**
- * @ORM\Column(type="boolean", nullable=true)
- */
- protected $isDefault;
-
- /**
- * @ORM\Column(type="string", length=32)
- */
- protected $color;
-
- /**
- * @ORM\ManyToMany(targetEntity="Lc\CaracoleBundle\Model\Product\ProductFamilyInterface", mappedBy="sections")
- */
- protected $productFamilies;
-
- /**
- * @ORM\OneToMany(targetEntity="Lc\CaracoleBundle\Model\Order\OrderShopInterface", mappedBy="section")
- */
- protected $orderShops;
-
- /**
- * @ORM\OneToMany(targetEntity="Lc\CaracoleBundle\Model\Product\ProductCategoryInterface", mappedBy="section")
- */
- protected $productCategories;
-
- /**
- * @ORM\OneToMany(targetEntity="Lc\SovBundle\Model\Site\NewsInterface", mappedBy="section", orphanRemoval=true)
- */
- protected $news;
-
- /**
- * @ORM\OneToMany(targetEntity="Lc\SovBundle\Model\Newsletter\NewsletterInterface", mappedBy="section")
- */
- protected $newsletters;
-
- /**
- * @ORM\OneToMany(targetEntity="Lc\SovBundle\Model\Site\PageInterface", mappedBy="section")
- */
- protected $pages;
-
- /**
- * @ORM\OneToMany(targetEntity="Lc\CaracoleBundle\Model\Setting\SectionSettingInterface", mappedBy="section", orphanRemoval=true, cascade={"persist"}, fetch="EAGER")
- */
- protected $settings;
-
- /**
- * @ORM\OneToMany(targetEntity="Lc\CaracoleBundle\Model\Section\OpeningInterface", mappedBy="section", orphanRemoval=true)
- */
- protected $openings;
-
- public function __construct()
- {
- $this->productFamilies = new ArrayCollection();
- $this->orderShops = new ArrayCollection();
- $this->productCategories = new ArrayCollection();
- $this->news = new ArrayCollection();
- $this->newsletters = new ArrayCollection();
- $this->pages = new ArrayCollection();
- $this->settings = new ArrayCollection();
- $this->openings = new ArrayCollection();
- }
-
- public function __toString()
- {
- return $this->getTitle();
- }
-
- public function getMerchant(): ?MerchantInterface
- {
- return $this->merchant;
- }
-
- public function setMerchant(?MerchantInterface $merchant): self
- {
- $this->merchant = $merchant;
-
- return $this;
- }
-
- public function getColor(): ?string
- {
- return $this->color;
- }
-
- public function setColor(string $color): self
- {
- $this->color = $color;
-
- return $this;
- }
-
- public function getCycleType(): ?string
- {
- return $this->cycleType;
- }
-
- public function setCycleType(string $cycleType): self
- {
- $this->cycleType = $cycleType;
-
- return $this;
- }
-
- /**
- * @return Collection|ProductFamilyInterface[]
- */
- public function getProductFamilies(): Collection
- {
- return $this->productFamilies;
- }
-
- public function addProductFamily(ProductFamilyInterface $productFamily): self
- {
- if (!$this->productFamilies->contains($productFamily)) {
- $this->productFamilies[] = $productFamily;
- $productFamily->addSection($this);
- }
-
- return $this;
- }
-
- public function removeProductFamily(ProductFamilyInterface $productFamily): self
- {
- if ($this->productFamilies->contains($productFamily)) {
- $this->productFamilies->removeElement($productFamily);
- $productFamily->removeSection($this);
- }
-
- return $this;
- }
-
- /**
- * @return Collection|OrderShopInterface[]
- */
- public function getOrderShops(): Collection
- {
- return $this->orderShops;
- }
-
- public function addOrderShop(OrderShopInterface $orderShop): self
- {
- if (!$this->orderShops->contains($orderShop)) {
- $this->orderShops[] = $orderShop;
- $orderShop->setSection($this);
- }
-
- return $this;
- }
-
- public function removeOrderShop(OrderShopInterface $orderShop): self
- {
- if ($this->orderShops->contains($orderShop)) {
- $this->orderShops->removeElement($orderShop);
- // set the owning side to null (unless already changed)
- if ($orderShop->getSection() === $this) {
- $orderShop->setSection(null);
- }
- }
-
- return $this;
- }
-
- /**
- * @return Collection|ProductCategoryInterface[]
- */
- public function getProductCategories(): Collection
- {
- return $this->productCategories;
- }
-
- public function addProductCategory(ProductCategoryInterface $productCategory): self
- {
- if (!$this->productCategories->contains($productCategory)) {
- $this->productCategories[] = $productCategory;
- $productCategory->setSection($this);
- }
-
- return $this;
- }
-
- public function removeProductCategory(ProductCategoryInterface $productCategory): self
- {
- if ($this->productCategories->contains($productCategory)) {
- $this->productCategories->removeElement($productCategory);
- // set the owning side to null (unless already changed)
- if ($productCategory->getSection() === $this) {
- $productCategory->setSection(null);
- }
- }
-
- return $this;
- }
-
- /**
- * @return Collection|PageInterface[]
- */
- public function getPages(): Collection
- {
- return $this->pages;
- }
-
- public function addPage(PageInterface $page): self
- {
- if (!$this->pages->contains($page)) {
- $this->pages[] = $page;
- $page->setSection($this);
- }
-
- return $this;
- }
-
- public function removePage(PageInterface $page): self
- {
- if ($this->pages->removeElement($page)) {
- // set the owning side to null (unless already changed)
- if ($page->getSection() === $this) {
- $page->setSection(null);
- }
- }
-
- return $this;
- }
-
- /**
- * @return Collection|NewsInterface[]
- */
- public function getNews(): Collection
- {
- return $this->news;
- }
-
- public function addNews(NewsInterface $news): self
- {
- if (!$this->news->contains($news)) {
- $this->news[] = $news;
- $news->setSection($this);
- }
-
- return $this;
- }
-
- public function removeNews(NewsInterface $news): self
- {
- if ($this->news->contains($news)) {
- $this->news->removeElement($news);
- // set the owning side to null (unless already changed)
- if ($news->getSection() === $this) {
- $news->setSection(null);
- }
- }
-
- return $this;
- }
-
- /**
- * @return Collection|NewsletterInterface[]
- */
- public function getNewsletters(): Collection
- {
- return $this->newsletters;
- }
-
- public function addNewsletter(NewsletterInterface $newsletter): self
- {
- if (!$this->newsletters->contains($newsletter)) {
- $this->newsletters[] = $newsletter;
- $newsletter->setSection($this);
- }
-
- return $this;
- }
-
- public function removeNewsletter(NewsletterInterface $newsletter): self
- {
- if ($this->newsletters->contains($newsletter)) {
- $this->newsletters->removeElement($newsletter);
- // set the owning side to null (unless already changed)
- if ($newsletter->getSection() === $this) {
- $newsletter->setSection(null);
- }
- }
-
- return $this;
- }
-
- public function getIsDefault(): ?bool
- {
- return $this->isDefault;
- }
-
- public function setIsDefault(?bool $isDefault): self
- {
- $this->isDefault = $isDefault;
-
- return $this;
- }
-
- /**
- * @return Collection|SectionSettingInterface[]
- */
- public function getSettings(): Collection
- {
- return $this->settings;
- }
-
- public function addSetting(SectionSettingInterface $sectionSetting): self
- {
- if (!$this->settings->contains($sectionSetting)) {
- $this->settings[] = $sectionSetting;
- $sectionSetting->setSection($this);
- }
-
- return $this;
- }
-
- public function removeSetting(SectionSettingInterface $sectionSetting): self
- {
- if ($this->settings->contains($sectionSetting)) {
- $this->settings->removeElement($sectionSetting);
- // set the owning side to null (unless already changed)
- if ($sectionSetting->getSection() === $this) {
- $sectionSetting->setSection(null);
- }
- }
-
- return $this;
- }
-
- /**
- * @return Collection|OpeningInterface[]
- */
- public function getOpenings(): Collection
- {
- return $this->openings;
- }
-
- public function addOpening(OpeningInterface $opening): self
- {
- if (!$this->openings->contains($opening)) {
- $this->openings[] = $opening;
- $opening->setSection($this);
- }
-
- return $this;
- }
-
- public function removeOpening(OpeningInterface $opening): self
- {
- if ($this->openings->removeElement($opening)) {
- // set the owning side to null (unless already changed)
- if ($opening->getSection() === $this) {
- $opening->setSection(null);
- }
- }
-
- return $this;
- }
- }
|