4 * This file is part of Twig.
6 * (c) 2009 Fabien Potencier
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.
15 * Use Twig_SimpleFilter instead.
17 * @author Fabien Potencier <fabien@symfony.com>
18 * @deprecated since 1.12 (to be removed in 2.0)
20 abstract class Twig_Filter
implements Twig_FilterInterface
, Twig_FilterCallableInterface
23 protected $arguments = array();
25 public function __construct(array $options = array())
27 $this->options
= array_merge(array(
28 'needs_environment' => false,
29 'needs_context' => false,
31 'preserves_safety' => null,
36 public function setArguments($arguments)
38 $this->arguments
= $arguments;
41 public function getArguments()
43 return $this->arguments
;
46 public function needsEnvironment()
48 return $this->options
['needs_environment'];
51 public function needsContext()
53 return $this->options
['needs_context'];
56 public function getSafe(Twig_Node
$filterArgs)
58 if (isset($this->options
['is_safe'])) {
59 return $this->options
['is_safe'];
62 if (isset($this->options
['is_safe_callback'])) {
63 return call_user_func($this->options
['is_safe_callback'], $filterArgs);
67 public function getPreservesSafety()
69 return $this->options
['preserves_safety'];
72 public function getPreEscape()
74 return $this->options
['pre_escape'];
77 public function getCallable()
79 return $this->options
['callable'];