<?php
declare(strict_types=1);
namespace App\Entity\Shipping;
use Doctrine\ORM\Mapping as ORM;
use Sylius\Component\Core\Model\ShippingMethod as BaseShippingMethod;
use Sylius\Component\Shipping\Model\ShippingMethodTranslationInterface;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Sylius\Component\Core\Model\ImagesAwareInterface;
use Sylius\Component\Core\Model\ImageInterface;
class ShippingMethod extends BaseShippingMethod implements ImagesAwareInterface
{
// Types de points retrait
public const PICKUP_TYPES = [
'none', // Aucun
'so_colissimo', // Point relais So Colissimo
'shop2shop', // Point relais Chronopost Shop2Shop
'shop', // Retrait en boutique
'apel'
];
protected $images;
protected $minDelayDays;
protected $maxDelayDays;
protected $deliveryOnSaturday;
protected $pickup;
protected $subtemplate;
public function __construct()
{
parent::__construct();
$this->images = new ArrayCollection();
$this->addImage(new ShippingMethodImage());
}
protected function createTranslation(): ShippingMethodTranslationInterface
{
return new ShippingMethodTranslation();
}
/**
* {@inheritdoc}
*/
public function getImages(): Collection
{
return $this->images;
}
/**
* {@inheritdoc}
*/
public function getImagesByType(string $type): Collection
{
return $this->images->filter(function (ImageInterface $image) use ($type) {
return $type === $image->getType();
});
}
/**
* {@inheritdoc}
*/
public function hasImages(): bool
{
return !$this->images->isEmpty();
}
/**
* {@inheritdoc}
*/
public function hasImage(ImageInterface $image): bool
{
return $this->images->contains($image);
}
/**
* {@inheritdoc}
*/
public function addImage(ImageInterface $image): void
{
$image->setOwner($this);
$this->images->add($image);
}
/**
* {@inheritdoc}
*/
public function removeImage(ImageInterface $image): void
{
if ($this->hasImage($image)) {
$image->setOwner(null);
$this->images->removeElement($image);
}
}
public function setMinDelayDays($minDelayDays)
{
$this->minDelayDays = $minDelayDays;
}
public function getMinDelayDays()
{
return $this->minDelayDays;
}
public function setMaxDelayDays($maxDelayDays)
{
$this->maxDelayDays = $maxDelayDays;
}
public function getMaxDelayDays()
{
return $this->maxDelayDays;
}
public function setDeliveryOnSaturday($deliveryOnSaturday)
{
$this->deliveryOnSaturday = $deliveryOnSaturday;
}
public function getDeliveryOnSaturday()
{
return $this->deliveryOnSaturday;
}
public function getPickup()
{
return $this->pickup;
}
public function setPickup($pickup)
{
$this->pickup = $pickup;
}
public function getSubtemplate()
{
return $this->subtemplate;
}
public function setSubtemplate($subtemplate)
{
$this->subtemplate = $subtemplate;
}
}