<?php
/*
* Copyright (C) SPREAD WORKS Inc. All Rights Reserved.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Plugin\TabaBannerManager2\EventListener;
use Eccube\Common\Constant;
use Eccube\Event\TemplateEvent;
use Plugin\TabaBannerManager2\Common\Constants;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface;
/**
* 注文完了ページにCVカウンターを設置します。
*/
class ConversionCounterListener implements EventSubscriberInterface
{
/**
* @var CsrfTokenManagerInterface
*/
private $csrfTokenManager;
/**
* コンストラクタ
*/
public function __construct(
CsrfTokenManagerInterface $csrfTokenManager
) {
$this->csrfTokenManager = $csrfTokenManager;
}
/**
* {@inheritdoc}
*
* @return array
*/
public static function getSubscribedEvents()
{
return [
'Shopping/complete.twig' => [['onTemplateShoppingComplete', 10]],
];
}
/**
* 注文完了ページにCVカウンターを設置します。
*
* @param TemplateEvent $templateEvent
*/
public function onTemplateShoppingComplete(TemplateEvent $templateEvent)
{
$templateEvent->setParameter('csrf_token',$this->csrfTokenManager->getToken(Constant::TOKEN_NAME)->getValue());
$templateEvent->addSnippet(Constants::TEMPLATE_ALIAS . '/default/snippet/shopping_complete.twig');
}
}