4 * This file is part of Twig.
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
13 * Represents a template filter.
17 * @author Fabien Potencier <fabien@symfony.com>
19 class Twig_SimpleFilter
24 protected $arguments = array();
26 public function __construct($name, $callable, array $options = array())
29 $this->callable = $callable;
30 $this->options = array_merge(array(
31 'needs_environment' => false,
32 'needs_context' => false,
33 'is_variadic' => false,
35 'is_safe_callback' => null,
37 'preserves_safety' => null,
38 'node_class' => 'Twig_Node_Expression_Filter',
39 'deprecated' => false,
40 'alternative' => null,
44 public function getName()
49 public function getCallable()
51 return $this->callable;
54 public function getNodeClass()
56 return $this->options['node_class'];
59 public function setArguments($arguments)
61 $this->arguments = $arguments;
64 public function getArguments()
66 return $this->arguments;
69 public function needsEnvironment()
71 return $this->options['needs_environment'];
74 public function needsContext()
76 return $this->options['needs_context'];
79 public function getSafe(Twig_Node $filterArgs)
81 if (null !== $this->options['is_safe']) {
82 return $this->options['is_safe'];
85 if (null !== $this->options['is_safe_callback']) {
86 return call_user_func($this->options['is_safe_callback'], $filterArgs);
90 public function getPreservesSafety()
92 return $this->options['preserves_safety'];
95 public function getPreEscape()
97 return $this->options['pre_escape'];
100 public function isVariadic()
102 return $this->options['is_variadic'];
105 public function isDeprecated()
107 return (bool) $this->options['deprecated'];
110 public function getDeprecatedVersion()
112 return $this->options['deprecated'];
115 public function getAlternative()
117 return $this->options['alternative'];