diff options
Diffstat (limited to 'inc/3rdparty/Twig/Function.php')
-rw-r--r-- | inc/3rdparty/Twig/Function.php | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/inc/3rdparty/Twig/Function.php b/inc/3rdparty/Twig/Function.php new file mode 100644 index 00000000..b5ffb2b0 --- /dev/null +++ b/inc/3rdparty/Twig/Function.php | |||
@@ -0,0 +1,71 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of Twig. | ||
5 | * | ||
6 | * (c) 2010 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 | * Use Twig_SimpleFunction instead. | ||
16 | * | ||
17 | * @author Fabien Potencier <fabien@symfony.com> | ||
18 | * @deprecated since 1.12 (to be removed in 2.0) | ||
19 | */ | ||
20 | abstract class Twig_Function implements Twig_FunctionInterface, Twig_FunctionCallableInterface | ||
21 | { | ||
22 | protected $options; | ||
23 | protected $arguments = array(); | ||
24 | |||
25 | public function __construct(array $options = array()) | ||
26 | { | ||
27 | $this->options = array_merge(array( | ||
28 | 'needs_environment' => false, | ||
29 | 'needs_context' => false, | ||
30 | 'callable' => null, | ||
31 | ), $options); | ||
32 | } | ||
33 | |||
34 | public function setArguments($arguments) | ||
35 | { | ||
36 | $this->arguments = $arguments; | ||
37 | } | ||
38 | |||
39 | public function getArguments() | ||
40 | { | ||
41 | return $this->arguments; | ||
42 | } | ||
43 | |||
44 | public function needsEnvironment() | ||
45 | { | ||
46 | return $this->options['needs_environment']; | ||
47 | } | ||
48 | |||
49 | public function needsContext() | ||
50 | { | ||
51 | return $this->options['needs_context']; | ||
52 | } | ||
53 | |||
54 | public function getSafe(Twig_Node $functionArgs) | ||
55 | { | ||
56 | if (isset($this->options['is_safe'])) { | ||
57 | return $this->options['is_safe']; | ||
58 | } | ||
59 | |||
60 | if (isset($this->options['is_safe_callback'])) { | ||
61 | return call_user_func($this->options['is_safe_callback'], $functionArgs); | ||
62 | } | ||
63 | |||
64 | return array(); | ||
65 | } | ||
66 | |||
67 | public function getCallable() | ||
68 | { | ||
69 | return $this->options['callable']; | ||
70 | } | ||
71 | } | ||