Completed
Push — master ( 5d7b87...24188c )
by David
14s
created

ThemeExtension::getFunctions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
4
namespace TheCodingMachine\CMS\Theme\Extensions;
5
6
7
class ThemeExtension extends \Twig_Extension
8
{
9
    /**
10
     * @var string
11
     */
12
    private $themeUrl;
13
14
    public function __construct(string $themeUrl)
15
    {
16
17
        $this->themeUrl = rtrim($themeUrl, '/').'/';
18
    }
19
20
    /**
21
     * Returns a list of functions to add to the existing list.
22
     *
23
     * @return \Twig_Function[]
24
     */
25
    public function getFunctions()
26
    {
27
        return [
28
            new \Twig_Function('theme', [$this, 'getThemeUrl']),
29
        ];
30
    }
31
32
    public function getThemeUrl(string $resource): string
33
    {
34
        return $this->themeUrl.$resource;
35
    }
36
}