Completed
Push — master ( 42428f...823cf3 )
by Leny
13:56 queued 06:50
created

SvgTwigExtension::getName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Victoire\Bundle\MediaBundle\Twig;
4
5
/**
6
 * MenuTwigExtension.
7
 */
8
class SvgTwigExtension extends \Twig_Extension
9
{
10
    protected $kernelRootDir;
11
12
    /**
13
     * SvgTwigExtension constructor.
14
     *
15
     * @param $kernelRootDir
16
     */
17
    public function __construct($kernelRootDir)
18
    {
19
        $this->kernelRootDir = $kernelRootDir;
20
    }
21
22
    public function getFunctions()
23
    {
24
        return [
25
            new \Twig_SimpleFunction('include_svg', [$this, 'includeSvg'], ['is_safe' => ['html']]),
26
        ];
27
    }
28
29
    public function includeSvg($url)
30
    {
31
        return file_get_contents($this->kernelRootDir.'/../web'.$url);
32
    }
33
34
    public function getName()
35
    {
36
        return 'victoire_media_svg_extension';
37
    }
38
}
39