|
- <?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\SovBundle\Doctrine\Pattern\AbstractFullEntity;
-
- /**
- * @ORM\MappedSuperclass()
- */
- abstract class SectionModel extends AbstractFullEntity implements FilterMerchantInterface
- {
- /**
- * @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Merchant\MerchantInterface")
- * @ORM\JoinColumn(nullable=false)
- */
- protected $merchant;
-
- /**
- * @ORM\Column(type="string", length=32)
- */
- protected $cycle;
-
- const SECTION_CYCLE_DAY = 'day';
- const SECTION_CYCLE_WEEK = 'week';
- const SECTION_CYCLE_MONTH = 'month';
- const SECTION_CYCLE_YEAR = 'year';
-
- /**
- * @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;
-
- public function __construct()
- {
- $this->productFamilies = new ArrayCollection();
- $this->orderShops = 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 getCycle(): ?string
- {
- return $this->cycle;
- }
-
- public function setCycle(string $cycle): self
- {
- $this->cycle = $cycle;
-
- 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;
- }
- }
|