From 874b8cbf002e9d8bf0ff39671e1501165016320a Mon Sep 17 00:00:00 2001 From: Michael Save Date: Mon, 9 Apr 2012 20:52:26 +1000 Subject: inc/contrib -> inc/lib --- inc/lib/Twig/Filter.php | 58 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 inc/lib/Twig/Filter.php (limited to 'inc/lib/Twig/Filter.php') diff --git a/inc/lib/Twig/Filter.php b/inc/lib/Twig/Filter.php new file mode 100644 index 00000000..9595a1a8 --- /dev/null +++ b/inc/lib/Twig/Filter.php @@ -0,0 +1,58 @@ + + */ +abstract class Twig_Filter implements Twig_FilterInterface +{ + protected $options; + + public function __construct(array $options = array()) + { + $this->options = array_merge(array( + 'needs_environment' => false, + 'needs_context' => false, + 'pre_escape' => null, + ), $options); + } + + public function needsEnvironment() + { + return $this->options['needs_environment']; + } + + public function needsContext() + { + return $this->options['needs_context']; + } + + public function getSafe(Twig_Node $filterArgs) + { + if (isset($this->options['is_safe'])) { + return $this->options['is_safe']; + } + + if (isset($this->options['is_safe_callback'])) { + return call_user_func($this->options['is_safe_callback'], $filterArgs); + } + + return array(); + } + + public function getPreEscape() + { + return $this->options['pre_escape']; + } +} -- cgit v1.3