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

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