src/Entity/Shipping/ShippingMethod.php line 16

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Entity\Shipping;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Sylius\Component\Core\Model\ShippingMethod as BaseShippingMethod;
  6. use Sylius\Component\Shipping\Model\ShippingMethodTranslationInterface;
  7. use Doctrine\Common\Collections\ArrayCollection;
  8. use Doctrine\Common\Collections\Collection;
  9. use Sylius\Component\Core\Model\ImagesAwareInterface;
  10. use Sylius\Component\Core\Model\ImageInterface;
  11. class ShippingMethod extends BaseShippingMethod implements ImagesAwareInterface
  12. {
  13.     // Types de points retrait
  14.     public const PICKUP_TYPES = [
  15.         'none'// Aucun
  16.         'so_colissimo'// Point relais So Colissimo
  17.         'shop2shop'// Point relais Chronopost Shop2Shop
  18.         'shop'// Retrait en boutique
  19.         'apel'
  20.     ];
  21.     
  22.     protected $images;
  23.     protected $minDelayDays;
  24.     protected $maxDelayDays;
  25.     protected $deliveryOnSaturday;
  26.     protected $pickup;
  27.     protected $subtemplate;
  28.     public function __construct()
  29.     {
  30.         parent::__construct();
  31.         $this->images = new ArrayCollection();
  32.         $this->addImage(new ShippingMethodImage());
  33.     }
  34.     protected function createTranslation(): ShippingMethodTranslationInterface
  35.     {
  36.         return new ShippingMethodTranslation();
  37.     }
  38.     
  39.     /**
  40.      * {@inheritdoc}
  41.      */
  42.     public function getImages(): Collection
  43.     {
  44.         return $this->images;
  45.     }
  46.     /**
  47.      * {@inheritdoc}
  48.      */
  49.     public function getImagesByType(string $type): Collection
  50.     {
  51.         return $this->images->filter(function (ImageInterface $image) use ($type) {
  52.             return $type === $image->getType();
  53.         });
  54.     }
  55.     /**
  56.      * {@inheritdoc}
  57.      */
  58.     public function hasImages(): bool
  59.     {
  60.         return !$this->images->isEmpty();
  61.     }
  62.     /**
  63.      * {@inheritdoc}
  64.      */
  65.     public function hasImage(ImageInterface $image): bool
  66.     {
  67.         return $this->images->contains($image);
  68.     }
  69.     /**
  70.      * {@inheritdoc}
  71.      */
  72.     public function addImage(ImageInterface $image): void
  73.     {
  74.         $image->setOwner($this);
  75.         $this->images->add($image);
  76.     }
  77.     /**
  78.      * {@inheritdoc}
  79.      */
  80.     public function removeImage(ImageInterface $image): void
  81.     {
  82.         if ($this->hasImage($image)) {
  83.             $image->setOwner(null);
  84.             $this->images->removeElement($image);
  85.         }
  86.     }
  87.     public function setMinDelayDays($minDelayDays)
  88.     {
  89.         $this->minDelayDays $minDelayDays;
  90.     }
  91.     public function getMinDelayDays()
  92.     {
  93.         return $this->minDelayDays;
  94.     }
  95.     public function setMaxDelayDays($maxDelayDays)
  96.     {
  97.         $this->maxDelayDays $maxDelayDays;
  98.     }
  99.     public function getMaxDelayDays()
  100.     {
  101.         return $this->maxDelayDays;
  102.     }
  103.     public function setDeliveryOnSaturday($deliveryOnSaturday)
  104.     {
  105.         $this->deliveryOnSaturday $deliveryOnSaturday;
  106.     }
  107.     public function getDeliveryOnSaturday()
  108.     {
  109.         return $this->deliveryOnSaturday;
  110.     }
  111.     public function getPickup()
  112.     {
  113.         return $this->pickup;
  114.     }
  115.     public function setPickup($pickup)
  116.     {
  117.         $this->pickup $pickup;
  118.     }
  119.     public function getSubtemplate()
  120.     {
  121.         return $this->subtemplate;
  122.     }
  123.     public function setSubtemplate($subtemplate)
  124.     {
  125.         $this->subtemplate $subtemplate;
  126.     }
  127. }