Completed
Push — master ( a12db9...82664b )
by Julito
86:55 queued 55:35
created

SettingsExtension::__construct()   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 1
dl 0
loc 4
rs 10
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
     * Load settings from given namespace.
42
     *
43
     * @param string $namespace
44
     *
45
     * @return array
46
     */
47
    public function getSettings($namespace)
48
    {
49
        return $this->helper->getSettings($namespace);
50
    }
51
52
    /**
53
     * @param $name
54
     * @return mixed
55
     */
56
    public function getSettingsParameter($name)
57
    {
58
        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...
59
        //return $this->getSettingsParameter($name);
60
    }
61
62
63
    /**
64
     * {@inheritdoc}
65
     */
66
    public function getName()
67
    {
68
        return 'chamilo_settings';
69
    }
70
}
71