<?php
namespace App\Entity;
use Knp\DoctrineBehaviors\Contract\Entity\SoftDeletableInterface;
use Knp\DoctrineBehaviors\Model\SoftDeletable\SoftDeletableTrait;
use Knp\DoctrineBehaviors\Model\Blameable\BlameableTrait;
use Knp\DoctrineBehaviors\Contract\Entity\BlameableInterface;
use Knp\DoctrineBehaviors\Model\Timestampable\TimestampableTrait;
use Knp\DoctrineBehaviors\Contract\Entity\TimestampableInterface;
use Knp\DoctrineBehaviors\Model\Translatable\TranslatableTrait;
use Knp\DoctrineBehaviors\Contract\Entity\TranslatableInterface;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
/**
* @Doctrine\ORM\Mapping\Entity
* @Doctrine\ORM\Mapping\Table(name="delivery_method")
*/
class DeliveryMethod implements TranslatableInterface, BlameableInterface, TimestampableInterface, SoftDeletableInterface {
use BlameableTrait;
use TimestampableTrait;
use TranslatableTrait;
use SoftDeletableTrait;
/**
* @Doctrine\ORM\Mapping\Id
* @Doctrine\ORM\Mapping\Column(type="integer")
* @Doctrine\ORM\Mapping\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @Doctrine\ORM\Mapping\ManyToMany(targetEntity="App\Entity\DeliveryCountry")
*/
protected $deliveryCountries;
/**
* @Doctrine\ORM\Mapping\ManyToMany(targetEntity="App\Entity\Language")
*/
protected $languages;
/**
* @Doctrine\ORM\Mapping\OneToMany(targetEntity="App\Entity\DeliveryPrice", mappedBy="deliveryMethod", cascade={"persist"})
*/
protected $prices;
/**
* Special form of delivery - dedicated only for specific products
* @Doctrine\ORM\Mapping\Column(type="boolean", options={"default"=0})
*/
protected $special;
/**
* @Doctrine\ORM\Mapping\ManyToMany(targetEntity="App\Entity\PaymentMethod")
*/
protected $paymentMethods;
/**
** @Doctrine\ORM\Mapping\ManyToOne(targetEntity="App\Entity\ProductVat", cascade={"all"})
** @Doctrine\ORM\Mapping\JoinColumn(name="vat_id", referencedColumnName="id", onDelete="CASCADE")
*/
protected $vat;
/**
* @var string
*
* @Doctrine\ORM\Mapping\Column(name="read_more_url", type="text", nullable=true)
*/
private $readMoreUrl;
/**
* Obsługa tłumaczeń
* @param $method
* @param $arguments
* @return mixed
*/
public function __call($method, $arguments)
{
return $this->proxyCurrentLocaleTranslation($method, $arguments);
}
public function getName(){
return $this->translate()->getName();
}
/**
* Constructor
*/
public function __construct()
{
$this->deliveryCountries = new \Doctrine\Common\Collections\ArrayCollection();
$this->prices = new \Doctrine\Common\Collections\ArrayCollection();
$this->paymentMethods = new \Doctrine\Common\Collections\ArrayCollection();
$this->languages = new ArrayCollection();
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Add deliveryCountry
*
* @param \App\Entity\DeliveryCountry $deliveryCountry
*
* @return DeliveryMethod
*/
public function addDeliveryCountry(\App\Entity\DeliveryCountry $deliveryCountry)
{
$this->deliveryCountries[] = $deliveryCountry;
return $this;
}
/**
* Remove deliveryCountry
*
* @param \App\Entity\DeliveryCountry $deliveryCountry
*/
public function removeDeliveryCountry(\App\Entity\DeliveryCountry $deliveryCountry)
{
$this->deliveryCountries->removeElement($deliveryCountry);
}
/**
* Get deliveryCountries
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getDeliveryCountries()
{
return $this->deliveryCountries;
}
/**
* Add price
*
* @param \App\Entity\DeliveryPrice $price
*
* @return DeliveryMethod
*/
public function addPrice(\App\Entity\DeliveryPrice $price)
{
$this->prices[] = $price;
return $this;
}
/**
* Remove price
*
* @param \App\Entity\DeliveryPrice $price
*/
public function removePrice(\App\Entity\DeliveryPrice $price)
{
$this->prices->removeElement($price);
}
/**
* Get prices
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getPrices()
{
return $this->prices;
}
/**
* Add paymentMethod
*
* @param \App\Entity\PaymentMethod $paymentMethod
*
* @return DeliveryMethod
*/
public function addPaymentMethod(\App\Entity\PaymentMethod $paymentMethod)
{
$this->paymentMethods[] = $paymentMethod;
return $this;
}
/**
* Remove paymentMethod
*
* @param \App\Entity\PaymentMethod $paymentMethod
*/
public function removePaymentMethod(\App\Entity\PaymentMethod $paymentMethod)
{
$this->paymentMethods->removeElement($paymentMethod);
}
/**
* Get paymentMethods
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getPaymentMethods()
{
return $this->paymentMethods;
}
/**
* Set vat
*
* @param \App\Entity\ProductVat $vat
*
* @return DeliveryMethod
*/
public function setVat(\App\Entity\ProductVat $vat = null)
{
$this->vat = $vat;
return $this;
}
/**
* Get vat
*
* @return \App\Entity\ProductVat
*/
public function getVat()
{
return $this->vat;
}
/**
* @return Collection|Language[]
*/
public function getLanguages(): Collection
{
return $this->languages;
}
public function addLanguage(Language $language): self
{
if (!$this->languages->contains($language)) {
$this->languages[] = $language;
}
return $this;
}
public function removeLanguage(Language $language): self
{
if ($this->languages->contains($language)) {
$this->languages->removeElement($language);
}
return $this;
}
public function getSpecial(): ?bool
{
return $this->special;
}
public function setSpecial(bool $special): self
{
$this->special = $special;
return $this;
}
/**
* @return string
*/
public function getReadMoreUrl()
{
return $this->readMoreUrl;
}
/**
* @param string $readMoreUrl
*/
public function setReadMoreUrl(string $readMoreUrl)
{
$this->readMoreUrl = $readMoreUrl;
}
}