<?php
namespace Customize;
use Eccube\Request\Context;
use Customize\EventSubscriber\ProductHistoryEventSubscriber;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\KernelEvents;
use Twig\Environment;
class Event implements EventSubscriberInterface
{
/** @var Context */
protected $requestContext;
/** @var Environment */
protected $twig;
/**
* Event constructor.
*
* @param Context $requestContext
* @param Environment $twig
*/
public function __construct(
Context $requestContext,
Environment $twig
)
{
$this->requestContext = $requestContext;
$this->twig = $twig;
}
/**
* @return array
*/
public static function getSubscribedEvents()
{
return [
KernelEvents::REQUEST => ['onKernelRequest', 100000000]
];
}
/**
* @param GetResponseEvent $event
*/
public function onKernelRequest(GetResponseEvent $event)
{
// 管理画面は除外
if ($this->requestContext->isAdmin()) {
return;
}
// ここで共通変数設定
$this->twig->addGlobal('get',@$_GET);
$this->twig->addGlobal('productHistory',"");
}
}
?>