diff options
author | Nicolas LÅ“uillet <nicolas.loeuillet@gmail.com> | 2013-08-02 22:43:56 +0200 |
---|---|---|
committer | Nicolas LÅ“uillet <nicolas.loeuillet@gmail.com> | 2013-08-02 22:43:56 +0200 |
commit | 8069e235fd2971675ee5fc05026ffa9bce5cbbb7 (patch) | |
tree | 872eaed228b5e1b031c21770fba1701106a52a39 /inc/3rdparty/Twig/SimpleFunction.php | |
parent | 45161a64026cec35fcf07659508143a6f55ddf57 (diff) | |
download | wallabag-8069e235fd2971675ee5fc05026ffa9bce5cbbb7.tar.gz wallabag-8069e235fd2971675ee5fc05026ffa9bce5cbbb7.tar.zst wallabag-8069e235fd2971675ee5fc05026ffa9bce5cbbb7.zip |
move Twig in 3rdparty
Diffstat (limited to 'inc/3rdparty/Twig/SimpleFunction.php')
-rw-r--r-- | inc/3rdparty/Twig/SimpleFunction.php | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/inc/3rdparty/Twig/SimpleFunction.php b/inc/3rdparty/Twig/SimpleFunction.php new file mode 100644 index 00000000..8ef6aca2 --- /dev/null +++ b/inc/3rdparty/Twig/SimpleFunction.php | |||
@@ -0,0 +1,84 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of Twig. | ||
5 | * | ||
6 | * (c) 2010-2012 Fabien Potencier | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | /** | ||
13 | * Represents a template function. | ||
14 | * | ||
15 | * @author Fabien Potencier <fabien@symfony.com> | ||
16 | */ | ||
17 | class Twig_SimpleFunction | ||
18 | { | ||
19 | protected $name; | ||
20 | protected $callable; | ||
21 | protected $options; | ||
22 | protected $arguments = array(); | ||
23 | |||
24 | public function __construct($name, $callable, array $options = array()) | ||
25 | { | ||
26 | $this->name = $name; | ||
27 | $this->callable = $callable; | ||
28 | $this->options = array_merge(array( | ||
29 | 'needs_environment' => false, | ||
30 | 'needs_context' => false, | ||
31 | 'is_safe' => null, | ||
32 | 'is_safe_callback' => null, | ||
33 | 'node_class' => 'Twig_Node_Expression_Function', | ||
34 | ), $options); | ||
35 | } | ||
36 | |||
37 | public function getName() | ||
38 | { | ||
39 | return $this->name; | ||
40 | } | ||
41 | |||
42 | public function getCallable() | ||
43 | { | ||
44 | return $this->callable; | ||
45 | } | ||
46 | |||
47 | public function getNodeClass() | ||
48 | { | ||
49 | return $this->options['node_class']; | ||
50 | } | ||
51 | |||
52 | public function setArguments($arguments) | ||
53 | { | ||
54 | $this->arguments = $arguments; | ||
55 | } | ||
56 | |||
57 | public function getArguments() | ||
58 | { | ||
59 | return $this->arguments; | ||
60 | } | ||
61 | |||
62 | public function needsEnvironment() | ||
63 | { | ||
64 | return $this->options['needs_environment']; | ||
65 | } | ||
66 | |||
67 | public function needsContext() | ||
68 | { | ||
69 | return $this->options['needs_context']; | ||
70 | } | ||
71 | |||
72 | public function getSafe(Twig_Node $functionArgs) | ||
73 | { | ||
74 | if (null !== $this->options['is_safe']) { | ||
75 | return $this->options['is_safe']; | ||
76 | } | ||
77 | |||
78 | if (null !== $this->options['is_safe_callback']) { | ||
79 | return call_user_func($this->options['is_safe_callback'], $functionArgs); | ||
80 | } | ||
81 | |||
82 | return array(); | ||
83 | } | ||
84 | } | ||