diff options
author | Nicolas LÅ“uillet <nicolas.loeuillet@gmail.com> | 2013-08-02 22:40:51 +0200 |
---|---|---|
committer | Nicolas LÅ“uillet <nicolas.loeuillet@gmail.com> | 2013-08-02 22:40:51 +0200 |
commit | a4565e88edbc8e3bd092a475469769c86a4c350c (patch) | |
tree | a6a3c935b03a23ff87575c8c315cf8ba78fe68c2 /inc/Twig/Function.php | |
parent | f6c9baab3efeec1d0efa151e276fc08d5b58f9e9 (diff) | |
download | wallabag-a4565e88edbc8e3bd092a475469769c86a4c350c.tar.gz wallabag-a4565e88edbc8e3bd092a475469769c86a4c350c.tar.zst wallabag-a4565e88edbc8e3bd092a475469769c86a4c350c.zip |
add Twig & refactor poche
Diffstat (limited to 'inc/Twig/Function.php')
-rw-r--r-- | inc/Twig/Function.php | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/inc/Twig/Function.php b/inc/Twig/Function.php new file mode 100644 index 00000000..b5ffb2b0 --- /dev/null +++ b/inc/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 | } | ||