|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172 |
- <?php
-
- namespace Lc\ShopBundle\Model;
-
- use App\Entity\Hub;
- use Doctrine\Common\Collections\ArrayCollection;
- use Doctrine\Common\Collections\Collection;
- use Doctrine\ORM\Mapping as ORM;
- use Lc\ShopBundle\Context\FilterMerchantInterface;
-
- /**
- * @ORM\MappedSuperclass()
- */
- abstract class Section extends AbstractDocumentEntity implements FilterMerchantInterface
- {
- /**
- * @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\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\ShopBundle\Context\ProductFamilyInterface", mappedBy="sections")
- */
- protected $productFamilies;
-
- /**
- * @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\OrderShopInterface", mappedBy="section")
- */
- protected $orderShops;
-
-
- /**
- * @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\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(): ?Hub
- {
- return $this->merchant;
- }
-
- public function setMerchant(?Hub $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|ProductFamily[]
- */
- public function getProductFamilies(): Collection
- {
- return $this->productFamilies;
- }
-
- public function addProductFamily(ProductFamily $productFamily): self
- {
- if (!$this->productFamilies->contains($productFamily)) {
- $this->productFamilies[] = $productFamily;
- $productFamily->addSection($this);
- }
-
- return $this;
- }
-
- public function removeProductFamily(ProductFamily $productFamily): self
- {
- if ($this->productFamilies->contains($productFamily)) {
- $this->productFamilies->removeElement($productFamily);
- $productFamily->removeSection($this);
- }
-
- return $this;
- }
-
- /**
- * @return Collection|OrderShop[]
- */
- public function getOrderShops(): Collection
- {
- return $this->orderShops;
- }
-
- public function addOrderShop(OrderShop $orderShop): self
- {
- if (!$this->orderShops->contains($orderShop)) {
- $this->orderShops[] = $orderShop;
- $orderShop->setSection($this);
- }
-
- return $this;
- }
-
- public function removeOrderShop(OrderShop $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|ProductCategory[]
- */
- public function getProductCategories(): Collection
- {
- return $this->productCategories;
- }
-
- public function addProductCategory(ProductCategory $productCategory): self
- {
- if (!$this->productCategories->contains($productCategory)) {
- $this->productCategories[] = $productCategory;
- $productCategory->setSection($this);
- }
-
- return $this;
- }
-
- public function removeProductCategory(ProductCategory $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;
- }
- }
|