src/Entity/DeliveryMethod.php line 24

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Knp\DoctrineBehaviors\Contract\Entity\SoftDeletableInterface;
  4. use Knp\DoctrineBehaviors\Model\SoftDeletable\SoftDeletableTrait;
  5. use Knp\DoctrineBehaviors\Model\Blameable\BlameableTrait;
  6. use Knp\DoctrineBehaviors\Contract\Entity\BlameableInterface;
  7. use Knp\DoctrineBehaviors\Model\Timestampable\TimestampableTrait;
  8. use Knp\DoctrineBehaviors\Contract\Entity\TimestampableInterface;
  9. use Knp\DoctrineBehaviors\Model\Translatable\TranslatableTrait;
  10. use Knp\DoctrineBehaviors\Contract\Entity\TranslatableInterface;
  11. use Doctrine\Common\Collections\ArrayCollection;
  12. use Doctrine\Common\Collections\Collection;
  13. /**
  14.  * @Doctrine\ORM\Mapping\Entity
  15.  * @Doctrine\ORM\Mapping\Table(name="delivery_method")
  16.  */
  17. class DeliveryMethod implements TranslatableInterfaceBlameableInterfaceTimestampableInterfaceSoftDeletableInterface  {
  18.     use BlameableTrait;
  19.     use TimestampableTrait;
  20.     use TranslatableTrait;
  21.     use SoftDeletableTrait;
  22.     
  23.     
  24.     
  25.     /**
  26.      * @Doctrine\ORM\Mapping\Id
  27.      * @Doctrine\ORM\Mapping\Column(type="integer")
  28.      * @Doctrine\ORM\Mapping\GeneratedValue(strategy="AUTO")
  29.      */
  30.     protected $id;
  31.     /**
  32.      * @Doctrine\ORM\Mapping\ManyToMany(targetEntity="App\Entity\DeliveryCountry")
  33.      */
  34.     protected $deliveryCountries;
  35.     /**
  36.      * @Doctrine\ORM\Mapping\ManyToMany(targetEntity="App\Entity\Language")
  37.      */
  38.     protected $languages;
  39.     /**
  40.      * @Doctrine\ORM\Mapping\OneToMany(targetEntity="App\Entity\DeliveryPrice", mappedBy="deliveryMethod", cascade={"persist"})
  41.      */
  42.     protected $prices;
  43.     /**
  44.      * Special form of delivery - dedicated only for specific products
  45.      * @Doctrine\ORM\Mapping\Column(type="boolean", options={"default"=0})
  46.      */
  47.     protected $special;
  48.     /**
  49.      * @Doctrine\ORM\Mapping\ManyToMany(targetEntity="App\Entity\PaymentMethod")
  50.      */
  51.     protected $paymentMethods;
  52.     /**
  53.      ** @Doctrine\ORM\Mapping\ManyToOne(targetEntity="App\Entity\ProductVat", cascade={"all"})
  54.      ** @Doctrine\ORM\Mapping\JoinColumn(name="vat_id", referencedColumnName="id", onDelete="CASCADE")
  55.      */
  56.     protected $vat;
  57.     /**
  58.      * @var string
  59.      *
  60.      * @Doctrine\ORM\Mapping\Column(name="read_more_url", type="text", nullable=true)
  61.      */
  62.     private $readMoreUrl;
  63.     /**
  64.      * Obsługa tłumaczeń
  65.      * @param $method
  66.      * @param $arguments
  67.      * @return mixed
  68.      */
  69.     public function __call($method$arguments)
  70.     {
  71.         return $this->proxyCurrentLocaleTranslation($method$arguments);
  72.     }
  73.     public function getName(){
  74.         return $this->translate()->getName();
  75.     }
  76.     /**
  77.      * Constructor
  78.      */
  79.     public function __construct()
  80.     {
  81.         $this->deliveryCountries = new \Doctrine\Common\Collections\ArrayCollection();
  82.         $this->prices = new \Doctrine\Common\Collections\ArrayCollection();
  83.         $this->paymentMethods = new \Doctrine\Common\Collections\ArrayCollection();
  84.         $this->languages = new ArrayCollection();
  85.     }
  86.     /**
  87.      * Get id
  88.      *
  89.      * @return integer
  90.      */
  91.     public function getId()
  92.     {
  93.         return $this->id;
  94.     }
  95.     /**
  96.      * Add deliveryCountry
  97.      *
  98.      * @param \App\Entity\DeliveryCountry $deliveryCountry
  99.      *
  100.      * @return DeliveryMethod
  101.      */
  102.     public function addDeliveryCountry(\App\Entity\DeliveryCountry $deliveryCountry)
  103.     {
  104.         $this->deliveryCountries[] = $deliveryCountry;
  105.         return $this;
  106.     }
  107.     /**
  108.      * Remove deliveryCountry
  109.      *
  110.      * @param \App\Entity\DeliveryCountry $deliveryCountry
  111.      */
  112.     public function removeDeliveryCountry(\App\Entity\DeliveryCountry $deliveryCountry)
  113.     {
  114.         $this->deliveryCountries->removeElement($deliveryCountry);
  115.     }
  116.     /**
  117.      * Get deliveryCountries
  118.      *
  119.      * @return \Doctrine\Common\Collections\Collection
  120.      */
  121.     public function getDeliveryCountries()
  122.     {
  123.         return $this->deliveryCountries;
  124.     }
  125.     /**
  126.      * Add price
  127.      *
  128.      * @param \App\Entity\DeliveryPrice $price
  129.      *
  130.      * @return DeliveryMethod
  131.      */
  132.     public function addPrice(\App\Entity\DeliveryPrice $price)
  133.     {
  134.         $this->prices[] = $price;
  135.         return $this;
  136.     }
  137.     /**
  138.      * Remove price
  139.      *
  140.      * @param \App\Entity\DeliveryPrice $price
  141.      */
  142.     public function removePrice(\App\Entity\DeliveryPrice $price)
  143.     {
  144.         $this->prices->removeElement($price);
  145.     }
  146.     /**
  147.      * Get prices
  148.      *
  149.      * @return \Doctrine\Common\Collections\Collection
  150.      */
  151.     public function getPrices()
  152.     {
  153.         return $this->prices;
  154.     }
  155.     /**
  156.      * Add paymentMethod
  157.      *
  158.      * @param \App\Entity\PaymentMethod $paymentMethod
  159.      *
  160.      * @return DeliveryMethod
  161.      */
  162.     public function addPaymentMethod(\App\Entity\PaymentMethod $paymentMethod)
  163.     {
  164.         $this->paymentMethods[] = $paymentMethod;
  165.         return $this;
  166.     }
  167.     /**
  168.      * Remove paymentMethod
  169.      *
  170.      * @param \App\Entity\PaymentMethod $paymentMethod
  171.      */
  172.     public function removePaymentMethod(\App\Entity\PaymentMethod $paymentMethod)
  173.     {
  174.         $this->paymentMethods->removeElement($paymentMethod);
  175.     }
  176.     /**
  177.      * Get paymentMethods
  178.      *
  179.      * @return \Doctrine\Common\Collections\Collection
  180.      */
  181.     public function getPaymentMethods()
  182.     {
  183.         return $this->paymentMethods;
  184.     }
  185.     /**
  186.      * Set vat
  187.      *
  188.      * @param \App\Entity\ProductVat $vat
  189.      *
  190.      * @return DeliveryMethod
  191.      */
  192.     public function setVat(\App\Entity\ProductVat $vat null)
  193.     {
  194.         $this->vat $vat;
  195.         return $this;
  196.     }
  197.     /**
  198.      * Get vat
  199.      *
  200.      * @return \App\Entity\ProductVat
  201.      */
  202.     public function getVat()
  203.     {
  204.         return $this->vat;
  205.     }
  206.     /**
  207.      * @return Collection|Language[]
  208.      */
  209.     public function getLanguages(): Collection
  210.     {
  211.         return $this->languages;
  212.     }
  213.     public function addLanguage(Language $language): self
  214.     {
  215.         if (!$this->languages->contains($language)) {
  216.             $this->languages[] = $language;
  217.         }
  218.         return $this;
  219.     }
  220.     public function removeLanguage(Language $language): self
  221.     {
  222.         if ($this->languages->contains($language)) {
  223.             $this->languages->removeElement($language);
  224.         }
  225.         return $this;
  226.     }
  227.     public function getSpecial(): ?bool
  228.     {
  229.         return $this->special;
  230.     }
  231.     public function setSpecial(bool $special): self
  232.     {
  233.         $this->special $special;
  234.         return $this;
  235.     }
  236.     /**
  237.      * @return string
  238.      */
  239.     public function getReadMoreUrl()
  240.     {
  241.         return $this->readMoreUrl;
  242.     }
  243.     /**
  244.      * @param string $readMoreUrl
  245.      */
  246.     public function setReadMoreUrl(string $readMoreUrl)
  247.     {
  248.         $this->readMoreUrl $readMoreUrl;
  249.     }
  250. }