|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace Lc\ShopBundle\Model; |
|
|
namespace Lc\ShopBundle\Model; |
|
|
|
|
|
|
|
|
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
|
|
|
|
|
use Doctrine\Common\Collections\Collection; |
|
|
use Doctrine\ORM\Mapping as ORM; |
|
|
use Doctrine\ORM\Mapping as ORM; |
|
|
|
|
|
use Lc\ShopBundle\Context\OrderProductInterface; |
|
|
use Lc\ShopBundle\Context\PriceInterface; |
|
|
use Lc\ShopBundle\Context\PriceInterface; |
|
|
|
|
|
use Lc\ShopBundle\Context\ProductInterface; |
|
|
use Lc\ShopBundle\Context\ProductPropertyInterface; |
|
|
use Lc\ShopBundle\Context\ProductPropertyInterface; |
|
|
use Lc\ShopBundle\Context\SortableInterface; |
|
|
use Lc\ShopBundle\Context\SortableInterface; |
|
|
use Lc\ShopBundle\Services\Price; |
|
|
use Lc\ShopBundle\Services\Price; |
|
|
|
|
|
|
|
|
*/ |
|
|
*/ |
|
|
protected $title; |
|
|
protected $title; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\OrderProductInterface", mappedBy="product", orphanRemoval=true, cascade={"remove"}) |
|
|
|
|
|
*/ |
|
|
|
|
|
protected $orderProducts ; |
|
|
|
|
|
|
|
|
|
|
|
public function __construct() |
|
|
|
|
|
{ |
|
|
|
|
|
$this->orderProducts = new ArrayCollection() ; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
public function getPriceInherited() |
|
|
public function getPriceInherited() |
|
|
{ |
|
|
{ |
|
|
if($this->price) { |
|
|
if($this->price) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return $this; |
|
|
return $this; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* @return Collection|OrderProductInterface[] |
|
|
|
|
|
*/ |
|
|
|
|
|
public function getOrderProducts(): Collection |
|
|
|
|
|
{ |
|
|
|
|
|
return $this->orderProducts; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function addOrderProduct(OrderProductInterface $orderProduct): self |
|
|
|
|
|
{ |
|
|
|
|
|
if (!$this->orderProducts->contains($orderProduct)) { |
|
|
|
|
|
$this->orderProducts[] = $orderProduct; |
|
|
|
|
|
$orderProduct->setProduct($this); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return $this; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function removeOrderProduct(OrderProductInterface $orderProduct): self |
|
|
|
|
|
{ |
|
|
|
|
|
if ($this->orderProducts->contains($orderProduct)) { |
|
|
|
|
|
$this->orderProducts->removeElement($orderProduct); |
|
|
|
|
|
// set the owning side to null (unless already changed) |
|
|
|
|
|
if ($orderProduct->getProduct() === $this) { |
|
|
|
|
|
$orderProduct->setProduct(null); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return $this; |
|
|
|
|
|
} |
|
|
} |
|
|
} |