app/Plugin/Paidy4/PaidyEvent.php line 54

Open in your IDE?
  1. <?php
  2. namespace Plugin\Paidy4;
  3. use Eccube\Common\EccubeConfig;
  4. use Eccube\Event\TemplateEvent;
  5. use Eccube\Repository\PaymentRepository;
  6. use Plugin\Paidy4\Repository\ConfigRepository;
  7. use Plugin\Paidy4\Service\Method\Paidy;
  8. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  9. class PaidyEvent implements EventSubscriberInterface
  10. {
  11.     /**
  12.      * @var OrderRepository
  13.      */
  14.     protected $eccubeConfig;
  15.     /**
  16.      * @var ConfigRepository
  17.      */
  18.     protected $configRepository;
  19.     /**
  20.      * @var PaymentRepository
  21.      */
  22.     protected $paymentRepository;
  23.     /**
  24.      * PaidyEvent
  25.      */
  26.     public function __construct(
  27.         EccubeConfig $eccubeConfig,
  28.         ConfigRepository $configRepository,
  29.         PaymentRepository $paymentRepository
  30.     ) {
  31.         $this->eccubeConfig $eccubeConfig;
  32.         $this->configRepository $configRepository;
  33.         $this->Config $this->configRepository->get();
  34.         $this->paymentRepository $paymentRepository;
  35.     }
  36.     /**
  37.      * {@inheritdoc}
  38.      */
  39.     public static function getSubscribedEvents()
  40.     {
  41.         return [
  42.             'Shopping/index.twig' => 'index',
  43.             'Shopping/confirm.twig' => 'confirm',
  44.         ];
  45.     }
  46.     public function index(TemplateEvent $event)
  47.     {
  48.         $Payment $this->paymentRepository->findOneBy(['method_class' => Paidy::class]);
  49.         if ($Payment && $this->Config['description_disp'] == 1) {
  50.             $parameters $event->getParameters();
  51.             $parameters['paidy_payment_id'] = $Payment->getId();
  52.             $parameters['plugin_config'] = $this->Config;
  53.             $parameters['paidy_customer_link'] = $this->eccubeConfig['paidy']['paidy_customer_link'];
  54.             $event->setParameters($parameters);
  55.             $event->addSnippet('@Paidy4/default/Shopping/paidy_shopping_info.twig');
  56.         }
  57.     }
  58.     public function confirm(TemplateEvent $event)
  59.     {
  60.         $event->addSnippet('@Paidy4/default/Shopping/confirm_button.twig');
  61.     }
  62. }