app/Plugin/TabaBannerManager2/EventListener/ConversionCounterListener.php line 52

Open in your IDE?
  1. <?php
  2. /*
  3.  * Copyright (C) SPREAD WORKS Inc. All Rights Reserved.
  4.  *
  5.  * For the full copyright and license information, please view the LICENSE
  6.  * file that was distributed with this source code.
  7.  */
  8. namespace Plugin\TabaBannerManager2\EventListener;
  9. use Eccube\Common\Constant;
  10. use Eccube\Event\TemplateEvent;
  11. use Plugin\TabaBannerManager2\Common\Constants;
  12. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  13. use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface;
  14. /**
  15.  * 注文完了ページにCVカウンターを設置します。
  16.  */
  17. class ConversionCounterListener implements EventSubscriberInterface
  18. {
  19.     /**
  20.      * @var CsrfTokenManagerInterface
  21.      */
  22.     private $csrfTokenManager;
  23.     /**
  24.      * コンストラクタ
  25.      */
  26.     public function __construct(
  27.         CsrfTokenManagerInterface $csrfTokenManager
  28.     ) {
  29.         $this->csrfTokenManager $csrfTokenManager;
  30.     }
  31.     /**
  32.      * {@inheritdoc}
  33.      *
  34.      * @return array
  35.      */
  36.     public static function getSubscribedEvents()
  37.     {
  38.         return [
  39.             'Shopping/complete.twig' => [['onTemplateShoppingComplete'10]],
  40.         ];
  41.     }
  42.     /**
  43.      * 注文完了ページにCVカウンターを設置します。
  44.      *
  45.      * @param TemplateEvent $templateEvent
  46.      */
  47.     public function onTemplateShoppingComplete(TemplateEvent $templateEvent)
  48.     {
  49.         $templateEvent->setParameter('csrf_token',$this->csrfTokenManager->getToken(Constant::TOKEN_NAME)->getValue());
  50.         $templateEvent->addSnippet(Constants::TEMPLATE_ALIAS '/default/snippet/shopping_complete.twig');
  51.     }
  52. }