for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Eccube\Service\PurchaseFlow\Processor;
use Eccube\Entity\ItemInterface;
use Eccube\Repository\DeliveryRepository;
use Eccube\Service\PurchaseFlow\ItemValidateException;
use Eccube\Service\PurchaseFlow\ValidatableItemProcessor;
use Eccube\Service\PurchaseFlow\PurchaseContext;
/**
* 商品種別に配送業者が設定されているかどうか.
*/
class DeliverySettingValidator extends ValidatableItemProcessor
{
* @var DeliveryRepository
protected $deliveryRepository;
public function __construct(DeliveryRepository $deliveryRepository)
$this->deliveryRepository = $deliveryRepository;
}
protected function validate(ItemInterface $item, PurchaseContext $context)
if (!$item->isProduct()) {
return;
$ProductType = $item->getProductClass()->getProductType();
$Deliveries = $this->deliveryRepository->findBy(['ProductType' => $ProductType]);
if (empty($Deliveries)) {
throw new ItemValidateException('cart.product.not.producttype', ['%product%' => $item->getProductClass()->getProduct()->getName()]);
protected function handle(ItemInterface $item, PurchaseContext $context)
$item->setQuantity(0);