app/Customize/Event.php line 48

Open in your IDE?
  1. <?php
  2. namespace Customize;
  3. use Eccube\Request\Context;
  4. use Customize\EventSubscriber\ProductHistoryEventSubscriber;
  5. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  6. use Symfony\Component\HttpKernel\Event\GetResponseEvent;
  7. use Symfony\Component\HttpKernel\KernelEvents;
  8. use Twig\Environment;
  9. class Event implements EventSubscriberInterface
  10. {
  11.     /** @var Context */
  12.     protected $requestContext;
  13.     /** @var Environment */
  14.     protected $twig;
  15.     /**
  16.      * Event constructor.
  17.      *
  18.      * @param Context $requestContext
  19.      * @param Environment $twig
  20.      */
  21.     public function __construct(
  22.         Context $requestContext,
  23.         Environment $twig
  24.     )
  25.     {
  26.         $this->requestContext $requestContext;
  27.         $this->twig $twig;
  28.     }
  29.     /**
  30.      * @return array
  31.      */
  32.     public static function getSubscribedEvents()
  33.     {
  34.         return [
  35.             KernelEvents::REQUEST => ['onKernelRequest'100000000]
  36.         ];
  37.     }
  38.     /**
  39.      * @param GetResponseEvent $event
  40.      */
  41.     public function onKernelRequest(GetResponseEvent $event)
  42.     {
  43.         // 管理画面は除外
  44.         if ($this->requestContext->isAdmin()) {
  45.             return;
  46.         }
  47.         //  ここで共通変数設定
  48.         $this->twig->addGlobal('get',@$_GET);
  49.         $this->twig->addGlobal('productHistory',"");
  50.     }
  51. }
  52. ?>