Completed
Push — master ( f7178d...176486 )
by Julito
37:24
created

SettingsExtension::getFilters()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/* For licensing terms, see /license.txt */
3
4
namespace Chamilo\SettingsBundle\Twig;
5
6
use Sylius\Bundle\SettingsBundle\Templating\Helper\SettingsHelper;
7
8
/**
9
 * Sylius settings extension for Twig.
10
 *
11
 * @author Paweł Jędrzejewski <[email protected]>
12
 */
13
class SettingsExtension extends \Twig_Extension
14
{
15
    /**
16
     * @var SettingsHelper
17
     */
18
    private $helper;
19
20
    /**
21
     * @param SettingsHelper $helper
22
     */
23
    public function __construct($helper)
24
    {
25
        $this->helper = $helper;
26
    }
27
28
    /**
29
     * {@inheritdoc}
30
     */
31
    public function getFunctions()
32
    {
33
        return array(
34
             new \Twig_SimpleFunction('chamilo_settings_all', array($this, 'getSettings')),
35
             new \Twig_SimpleFunction('chamilo_settings_get', array($this, 'getSettingsParameter')),
36
             new \Twig_SimpleFunction('chamilo_settings_has', [$this, 'hasSettingsParameter']),
37
        );
38
    }
39
40
    /**
41
     *
42
     * {@inheritdoc}
43
     */
44
    public function getFilters()
45
    {
46
        return array(
47
             //new \Twig_SimpleFunction('chamilo_settings_all', array($this, 'getSettings')),
48
             new \Twig_SimpleFilter('get_setting', array($this, 'getSettingsParameter')),
49
             //new \Twig_SimpleFunction('chamilo_settings_has', [$this, 'hasSettingsParameter']),
50
        );
51
    }
52
53
    /**
54
     * Load settings from given namespace.
55
     *
56
     * @param string $namespace
57
     *
58
     * @return array
59
     */
60
    public function getSettings($namespace)
61
    {
62
        return $this->helper->getSettings($namespace);
63
    }
64
65
    /**
66
     * @param $name
67
     * @return mixed
68
     */
69
    public function getSettingsParameter($name)
70
    {
71
        return $this->helper->getSettingsParameter($name);
0 ignored issues
show
Bug introduced by
The method getSettingsParameter() does not exist on Sylius\Bundle\SettingsBu...g\Helper\SettingsHelper. Did you maybe mean getSettings()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
72
        //return $this->getSettingsParameter($name);
73
    }
74
75
76
    /**
77
     * {@inheritdoc}
78
     */
79
    public function getName()
80
    {
81
        return 'chamilo_settings';
82
    }
83
}
84