<?php
/**
* Copyright(c) 2022 SYSTEM_KD
* Date: 2022/11/19
*/
namespace Plugin\OrderStatusEx\EventSubscriber;
use Eccube\Entity\Master\OrderStatus;
use Eccube\Event\EventArgs;
use Plugin\OrderStatusEx\Entity\OrderStatusEvent;
use Plugin\OrderStatusEx\Repository\OrderStatusEventRepository;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class PointExDxEventSubscriber implements EventSubscriberInterface
{
/** @var OrderStatusEventRepository */
protected $orderStatusEventRepository;
public function __construct(
OrderStatusEventRepository $orderStatusEventRepository
)
{
$this->orderStatusEventRepository = $orderStatusEventRepository;
}
/**
* ポイント拡張プラグイン
* 初回購入と判定する受注状況の差し替え
*
* @param EventArgs $event
* @return void
*/
public function onPointExDxHookStatus(EventArgs $event)
{
$targets = $this->orderStatusEventRepository->getNoOrderStatusEvents();
// キャンセル対象を置き換え
$exclude = [
OrderStatus::PENDING,
OrderStatus::PROCESSING,
];
/** @var OrderStatusEvent $target */
foreach ($targets as $target) {
$exclude[] = $target->getOrderStatusId();
}
$event->setArgument('exclude', $exclude);
}
public static function getSubscribedEvents()
{
return [
'point_ex_dx.hook_states' => 'onPointExDxHookStatus'
];
}
}