Completed
Pull Request — master (#1)
by
unknown
12:25
created

HTML5CacheExtension::initRuntime()   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 1
1
<?php
2
3
namespace Evheniy\HTML5CacheBundle\Twig;
4
5
/**
6
 * Class HTML5CacheExtension
7
 *
8
 * @package Evheniy\HTML5CacheBundle\Twig
9
 */
10
class HTML5CacheExtension extends \Twig_Extension
11
{
12
    /**
13
     * @var \Twig_Environment
14
     */
15
    protected $environment;
16
17
    /**
18
     * @return \Twig_SimpleFunction[]
19
     */
20
    public function getFunctions()
21
    {
22
        return array(
23
            new \Twig_SimpleFunction('cache_manifest', array($this, 'getCacheManifest'))
24
        );
25
    }
26
27
    /**
28
     * @param \Twig_Environment $environment
29
     */
30
    public function needs_environment(\Twig_Environment $environment)
31
    {
32
        $this->environment = $environment;
33
    }
34
35
    /**
36
     * @return string
37
     */
38
    public function getCacheManifest()
39
    {
40
        return $this->environment->isDebug() ? '' : ' manifest="/cache.manifest"';
41
    }
42
43
    /**
44
     * Returns the name of the extension.
45
     *
46
     * @return string The extension name
47
     */
48
    public function getName()
49
    {
50
        return 'html5_cache_extension';
51
    }
52
}
53