|
|
@@ -2,6 +2,8 @@ |
|
|
|
|
|
|
|
namespace Lc\ShopBundle\Model; |
|
|
|
|
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
|
|
|
use Doctrine\Common\Collections\Collection; |
|
|
|
use Doctrine\ORM\Mapping as ORM; |
|
|
|
|
|
|
|
/** |
|
|
@@ -9,6 +11,12 @@ use Doctrine\ORM\Mapping as ORM; |
|
|
|
*/ |
|
|
|
class Section extends AbstractDocumentEntity |
|
|
|
{ |
|
|
|
/** |
|
|
|
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\MerchantInterface") |
|
|
|
* @ORM\JoinColumn(nullable=false) |
|
|
|
*/ |
|
|
|
protected $merchant; |
|
|
|
|
|
|
|
/** |
|
|
|
* @ORM\Column(type="string", length=32) |
|
|
|
*/ |
|
|
@@ -19,6 +27,22 @@ class Section extends AbstractDocumentEntity |
|
|
|
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; |
|
|
|
|
|
|
|
public function __construct() |
|
|
|
{ |
|
|
|
$this->productFamilies = new ArrayCollection(); |
|
|
|
$this->orderShops = new ArrayCollection(); |
|
|
|
} |
|
|
|
|
|
|
|
public function getCycle(): ?string |
|
|
|
{ |
|
|
|
return $this->cycle; |
|
|
@@ -30,4 +54,63 @@ class Section extends AbstractDocumentEntity |
|
|
|
|
|
|
|
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; |
|
|
|
} |
|
|
|
} |