src/Eccube/Twig/Template.php line 40

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of EC-CUBE
  4.  *
  5.  * Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
  6.  *
  7.  * http://www.ec-cube.co.jp/
  8.  *
  9.  * For the full copyright and license information, please view the LICENSE
  10.  * file that was distributed with this source code.
  11.  */
  12. namespace Eccube\Twig;
  13. use Eccube\Event\TemplateEvent;
  14. use Symfony\Component\EventDispatcher\EventDispatcherInterface;
  15. class Template extends \Twig\Template
  16. {
  17.     /**
  18.      * {@inheritdoc}
  19.      *
  20.      * @throws \Twig\Error\LoaderError
  21.      * @throws \Twig\Error\SyntaxError
  22.      */
  23.     public function display(array $context, array $blocks = [])
  24.     {
  25.         $globals $this->env->getGlobals();
  26.         if (isset($globals['event_dispatcher']) && strpos($this->getTemplateName(), '__string_template__') !== 0) {
  27.             /** @var EventDispatcherInterface $eventDispatcher */
  28.             $eventDispatcher $globals['event_dispatcher'];
  29.             $originCode $this->env->getLoader()->getSourceContext($this->getTemplateName())->getCode();
  30.             $event = new TemplateEvent($this->getTemplateName(), $originCode$context);
  31.             $eventDispatcher->dispatch($this->getTemplateName(), $event);
  32.             if ($event->getSource() !== $originCode) {
  33.                 $newTemplate $this->env->createTemplate($event->getSource());
  34.                 $newTemplate->display($event->getParameters(), $blocks);
  35.             } else {
  36.                 parent::display($event->getParameters(), $blocks);
  37.             }
  38.         } else {
  39.             parent::display($context$blocks);
  40.         }
  41.     }
  42.     public function getTemplateName()
  43.     {
  44.         // Templateのキャッシュ作成時に動的に作成されるメソッド
  45.         // デバッグツールバーでエラーが発生するため空文字を返しておく。
  46.         // @see https://github.com/EC-CUBE/ec-cube/issues/4529
  47.         return '';
  48.     }
  49.     public function getDebugInfo()
  50.     {
  51.         // Templateのキャッシュ作成時に動的に作成されるメソッド
  52.         return [];
  53.     }
  54.     protected function doDisplay(array $context, array $blocks = [])
  55.     {
  56.         // Templateのキャッシュ作成時に動的に作成されるメソッド
  57.     }
  58. }