app/Plugin/GmoPaymentGateway42/Event.php line 98

Open in your IDE?
  1. <?php
  2. /*
  3.  * Copyright(c) 2022 GMO Payment Gateway, Inc. All rights reserved.
  4.  * http://www.gmo-pg.com/
  5.  */
  6. namespace Plugin\GmoPaymentGateway42;
  7. use Eccube\Event\TemplateEvent;
  8. use Plugin\GmoPaymentGateway42\Service\FraudDetector;
  9. use Plugin\GmoPaymentGateway42\Service\Method\CreditCard;
  10. use Plugin\GmoPaymentGateway42\Service\PaymentHelperCredit;
  11. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  12. class Event implements EventSubscriberInterface
  13. {
  14.     /**
  15.      * @var Plugin\GmoPaymentGateway42\Service\FraudDetector
  16.      */
  17.     protected $FraudDetector;
  18.     /**
  19.      * @var Plugin\GmoPaymentGateway42\Service\PaymentHelperCredit
  20.      */
  21.     protected $PaymentHelperCredit;
  22.     /**
  23.      * コンストラクタ
  24.      *
  25.      * @param FraudDetector $FraudDetector
  26.      * @param PaymentHelperCredit $PaymentHelperCredit
  27.      */
  28.     public function __construct(
  29.         FraudDetector $FraudDetector,
  30.         PaymentHelperCredit $PaymentHelperCredit
  31.     ) {
  32.         $this->FraudDetector $FraudDetector;
  33.         $this->PaymentHelperCredit $PaymentHelperCredit;
  34.         // 不正検知機能を初期化
  35.         $this->FraudDetector->initPaymentMethodClass(CreditCard::class);
  36.     }
  37.     /**
  38.      * @return array
  39.      */
  40.     public static function getSubscribedEvents()
  41.     {
  42.         return [
  43.             '@admin/Setting/Shop/payment_edit.twig'
  44.                 => 'onAdminSettingShopPaymentEditTwig',
  45.             '@admin/Order/edit.twig' => 'onAdminOrderEditTwig',
  46.             '@admin/Customer/edit.twig' => 'onAdminCustomerEditTwig',
  47.             'Shopping/index.twig' => 'onDefaultShoppingIndexTwig',
  48.             'Shopping/confirm.twig' => 'onDefaultShoppingConfirmTwig',
  49.             'Shopping/complete.twig' => 'onDefaultShoppingCompleteTwig',
  50.             'Mypage/index.twig' => 'onDefaultMypageNaviTwig',
  51.             'Mypage/history.twig' => 'onDefaultMypageNaviTwig',
  52.             'Mypage/favorite.twig' => 'onDefaultMypageNaviTwig',
  53.             'Mypage/change.twig' => 'onDefaultMypageNaviTwig',
  54.             'Mypage/change_complete.twig' => 'onDefaultMypageNaviTwig',
  55.             'Mypage/delivery.twig' => 'onDefaultMypageNaviTwig',
  56.             'Mypage/delivery_edit.twig' => 'onDefaultMypageNaviTwig',
  57.             'Mypage/withdraw.twig' => 'onDefaultMypageNaviTwig',
  58.             '@GmoPaymentGateway42/mypage_card.twig'
  59.                 => 'onDefaultMypageNaviTwig',
  60.         ];
  61.     }
  62.     /**
  63.      * 管理画面 -> 設定 -> 店舗設定 -> 支払方法設定
  64.      */
  65.     public function onAdminSettingShopPaymentEditTwig(TemplateEvent $event)
  66.     {
  67.         $event->addSnippet('@GmoPaymentGateway42/admin/payment_edit.twig');
  68.     }
  69.     /**
  70.      * 管理画面 -> 受注管理 -> 受注一覧 -> 受注修正
  71.      */
  72.     public function onAdminOrderEditTwig(TemplateEvent $event)
  73.     {
  74.         $event->addSnippet('@GmoPaymentGateway42/admin/order_edit.twig');
  75.     }
  76.     /**
  77.      * 管理画面 -> 会員管理 -> 会員一覧 -> 会員修正
  78.      */
  79.     public function onAdminCustomerEditTwig(TemplateEvent $event)
  80.     {
  81.         $event->addSnippet('@GmoPaymentGateway42/admin/customer_edit.twig');
  82.     }
  83.     /**
  84.      * フロント -> 商品購入
  85.      */
  86.     public function onDefaultShoppingIndexTwig(TemplateEvent $event)
  87.     {
  88.         // 不正検知サービスを渡す
  89.         $event->setParameter('FraudDetector'$this->FraudDetector);
  90.         $event->addSnippet('@GmoPaymentGateway42/payment.twig');
  91.     }
  92.     /**
  93.      * フロント -> 商品購入(確認)
  94.      */
  95.     public function onDefaultShoppingConfirmTwig(TemplateEvent $event)
  96.     {
  97.         $event->addSnippet('@GmoPaymentGateway42/payment_confirm.twig');
  98.     }
  99.     /**
  100.      * フロント -> 商品購入(完了)
  101.      */
  102.     public function onDefaultShoppingCompleteTwig(TemplateEvent $event)
  103.     {
  104.         $event->addSnippet('@GmoPaymentGateway42/payment_complete.twig');
  105.     }
  106.     /**
  107.      * フロント -> マイページ -> ナビ
  108.      */
  109.     public function onDefaultMypageNaviTwig(TemplateEvent $event)
  110.     {
  111.         $event->setParameter
  112.             ('isAvailableCardEdit',
  113.              $this->PaymentHelperCredit->isAvailableCardEdit());
  114.         $event->addSnippet('@GmoPaymentGateway42/mypage_navi.twig');
  115.     }
  116. }