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