4 * This file is part of Twig.
6 * (c) 2010 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 function.
15 * Use Twig_SimpleFunction instead.
17 * @author Fabien Potencier <fabien@symfony.com>
18 * @deprecated since 1.12 (to be removed in 2.0)
20 abstract class Twig_Function
implements Twig_FunctionInterface
, Twig_FunctionCallableInterface
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,
34 public function setArguments($arguments)
36 $this->arguments
= $arguments;
39 public function getArguments()
41 return $this->arguments
;
44 public function needsEnvironment()
46 return $this->options
['needs_environment'];
49 public function needsContext()
51 return $this->options
['needs_context'];
54 public function getSafe(Twig_Node
$functionArgs)
56 if (isset($this->options
['is_safe'])) {
57 return $this->options
['is_safe'];
60 if (isset($this->options
['is_safe_callback'])) {
61 return call_user_func($this->options
['is_safe_callback'], $functionArgs);
67 public function getCallable()
69 return $this->options
['callable'];