Selaa lähdekoodia

Modèle Section : Lien ProductFamily et OrderShop

feature/module_traiteur_v1
Guillaume 3 vuotta sitten
vanhempi
commit
020df0b69b
3 muutettua tiedostoa jossa 132 lisäystä ja 2 poistoa
  1. +18
    -1
      ShopBundle/Model/OrderShop.php
  2. +31
    -1
      ShopBundle/Model/ProductFamily.php
  3. +83
    -0
      ShopBundle/Model/Section.php

+ 18
- 1
ShopBundle/Model/OrderShop.php Näytä tiedosto

@@ -117,12 +117,17 @@ abstract class OrderShop extends AbstractEntity implements FilterMerchantInterfa
*/
protected $updatedBy;


/**
* @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\TicketInterface", mappedBy="orderShop")
*/
protected $tickets;

/**
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\SectionInterface", inversedBy="orderShops")
* @ORM\JoinColumn(nullable=false)
*/
protected $section;

public function __construct()
{
$this->orderStatusHistories = new ArrayCollection();
@@ -572,4 +577,16 @@ abstract class OrderShop extends AbstractEntity implements FilterMerchantInterfa
return false ;
}

public function getSection(): ?Section
{
return $this->section;
}

public function setSection(?Section $section): self
{
$this->section = $section;

return $this;
}

}

+ 31
- 1
ShopBundle/Model/ProductFamily.php Näytä tiedosto

@@ -222,12 +222,16 @@ abstract class ProductFamily extends AbstractDocumentEntity implements ProductPr
*/
protected $behaviorPrice;


/**
* @ORM\Column(type="boolean")
*/
protected $saleStatus;

/**
* @ORM\ManyToMany(targetEntity="Lc\ShopBundle\Context\SectionInterface", inversedBy="productFamilies")
*/
protected $sections;

public function __construct()
{
$this->productCategories = new ArrayCollection();
@@ -857,4 +861,30 @@ abstract class ProductFamily extends AbstractDocumentEntity implements ProductPr

return $this;
}

/**
* @return Collection|Section[]
*/
public function getSections(): Collection
{
return $this->sections;
}

public function addSection(Section $section): self
{
if (!$this->sections->contains($section)) {
$this->sections[] = $section;
}

return $this;
}

public function removeSection(Section $section): self
{
if ($this->sections->contains($section)) {
$this->sections->removeElement($section);
}

return $this;
}
}

+ 83
- 0
ShopBundle/Model/Section.php Näytä tiedosto

@@ -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;
}
}

Loading…
Peruuta
Tallenna