<?php
namespace Customize;
use Eccube\Request\Context;
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()
{
if ($this->requestContext->isAdmin()) {
return;
}
$isProd = $_SERVER['APP_ENV'] === 'prod';
$this->twig->addGlobal('IS_PROD', $isProd);
}
}