src/Eccube/Twig/Extension/TwigIncludeExtension.php line 36

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\Extension;
  13. use Twig\Extension\AbstractExtension;
  14. use Twig\TwigFunction;
  15. class TwigIncludeExtension extends AbstractExtension
  16. {
  17.     protected $twig;
  18.     public function __construct(\Twig\Environment $twig)
  19.     {
  20.         $this->twig $twig;
  21.     }
  22.     public function getFunctions()
  23.     {
  24.         return [
  25.             new TwigFunction('include_dispatch', [$this'include_dispatch'],
  26.                 ['needs_context' => true'is_safe' => ['all']]),
  27.         ];
  28.     }
  29.     public function include_dispatch($context$template$variables = [])
  30.     {
  31.         if (!empty($variables)) {
  32.             $context array_merge($context$variables);
  33.         }
  34.         return $this->twig->render($template$context);
  35.     }
  36. }