app/Customize/Service/OrderStateMachine.php line 70

Open in your IDE?
  1. <?php
  2. namespace Customize\Service;
  3. use Eccube\Entity\Master\OrderStatus;
  4. use Eccube\Entity\Order;
  5. use Eccube\Repository\Master\OrderStatusRepository;
  6. use Eccube\Service\PurchaseFlow\Processor\PointProcessor;
  7. use Eccube\Service\PurchaseFlow\Processor\StockReduceProcessor;
  8. use Eccube\Service\PurchaseFlow\PurchaseContext;
  9. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  10. use Symfony\Component\Workflow\Event\Event;
  11. use Symfony\Component\Workflow\StateMachine;
  12. class OrderStateMachine implements EventSubscriberInterface
  13. {
  14.     /**
  15.      * @var StateMachine
  16.      */
  17.     private $machine;
  18.     /**
  19.      * @var OrderStatusRepository
  20.      */
  21.     private $orderStatusRepository;
  22.     /**
  23.      * @var PointProcessor
  24.      */
  25.     private $pointProcessor;
  26.     /**
  27.      * @var StockReduceProcessor
  28.      */
  29.     private $stockReduceProcessor;
  30.     /**
  31.      * @var MailService
  32.      */
  33.     protected $mailService;
  34.     public function __construct(StateMachine $_orderStateMachineOrderStatusRepository $orderStatusRepositoryPointProcessor $pointProcessorStockReduceProcessor $stockReduceProcessorMailService $mailService)
  35.     {
  36.         $this->machine $_orderStateMachine;
  37.         $this->orderStatusRepository $orderStatusRepository;
  38.         $this->pointProcessor $pointProcessor;
  39.         $this->stockReduceProcessor $stockReduceProcessor;
  40.         $this->mailService $mailService;
  41.     }
  42.     /**
  43.      * {@inheritdoc}
  44.      */
  45.     public static function getSubscribedEvents()
  46.     {
  47.         return [
  48.             //'workflow.order.completed' => ['onCompleted'],
  49.             'workflow.order.transition.pay' => ['sendPaymentMail'],
  50.             'workflow.order.transition.cancel' => ['sendCancelMail'],
  51.             // 'workflow.order.transition.back_to_in_progress' => [['commitStock'], ['commitUsePoint']],
  52.             // 'workflow.order.transition.ship' => [['commitAddPoint']],
  53.             // 'workflow.order.transition.return' => [['rollbackUsePoint'], ['rollbackAddPoint']],
  54.             // 'workflow.order.transition.cancel_return' => [['commitUsePoint'], ['commitAddPoint']],
  55.         ];
  56.     }
  57.     /*
  58.      * Event handlers.
  59.      */
  60.     public function sendPaymentMail(Event $event)
  61.     {
  62.         /* @var Order $Order */
  63.         $Order $event->getSubject()->getOrder();
  64.         $this->mailService->sendPaymentMail($Order);
  65.     }
  66.     public function sendCancelMail(Event $event)
  67.     {
  68.         /* @var Order $Order */
  69.         $Order $event->getSubject()->getOrder();
  70.         $this->mailService->sendCancelMail($Order);
  71.     }
  72. }