]> git.immae.eu Git - github/wallabag/wallabag.git/blob - vendor/twig/twig/lib/Twig/Filter.php
twig implementation
[github/wallabag/wallabag.git] / vendor / twig / twig / lib / Twig / Filter.php
1 <?php
2
3 /*
4 * This file is part of Twig.
5 *
6 * (c) 2009 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 filter.
14 *
15 * Use Twig_SimpleFilter 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_Filter implements Twig_FilterInterface, Twig_FilterCallableInterface
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 'pre_escape' => null,
31 'preserves_safety' => null,
32 'callable' => null,
33 ), $options);
34 }
35
36 public function setArguments($arguments)
37 {
38 $this->arguments = $arguments;
39 }
40
41 public function getArguments()
42 {
43 return $this->arguments;
44 }
45
46 public function needsEnvironment()
47 {
48 return $this->options['needs_environment'];
49 }
50
51 public function needsContext()
52 {
53 return $this->options['needs_context'];
54 }
55
56 public function getSafe(Twig_Node $filterArgs)
57 {
58 if (isset($this->options['is_safe'])) {
59 return $this->options['is_safe'];
60 }
61
62 if (isset($this->options['is_safe_callback'])) {
63 return call_user_func($this->options['is_safe_callback'], $filterArgs);
64 }
65 }
66
67 public function getPreservesSafety()
68 {
69 return $this->options['preserves_safety'];
70 }
71
72 public function getPreEscape()
73 {
74 return $this->options['pre_escape'];
75 }
76
77 public function getCallable()
78 {
79 return $this->options['callable'];
80 }
81 }