Completed
Push — experimental/sf ( 0de2cd...dd9b91 )
by
unknown
62:10
created

TwigIncludeExtension   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
dl 0
loc 26
rs 10
c 0
b 0
f 0
wmc 4
lcom 1
cbo 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getFunctions() 0 7 1
A include_dispatch() 0 8 2
1
<?php
2
3
/*
4
 * This file is part of EC-CUBE
5
 *
6
 * Copyright(c) LOCKON CO.,LTD. All Rights Reserved.
7
 *
8
 * http://www.lockon.co.jp/
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Eccube\Twig\Extension;
15
16
use Twig\Extension\AbstractExtension;
17
18
class TwigIncludeExtension extends AbstractExtension
19
{
20
    protected $twig;
21
22
    public function __construct(\Eccube\Twig\Environment $twig)
23
    {
24
        $this->twig = $twig;
25
    }
26
27
    public function getFunctions()
28
    {
29
        return [
30
            new \Twig_Function('include_dispatch', [$this, 'include_dispatch'],
31
                array('needs_context' => true, 'is_safe' => array('all'))),
32
        ];
33
    }
34
35
    public function include_dispatch($context, $template, $variables = [])
36
    {
37
        if (!empty($variables)) {
38
            $context = array_merge($context, $variables);
39
        }
40
41
        return $this->twig->render($template, $context);
42
    }
43
}
44