]>
git.immae.eu Git - github/wallabag/wallabag.git/blob - vendor/twig/twig/lib/Twig/SimpleFunction.php
4 * This file is part of Twig.
6 * (c) 2010-2012 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 * @author Fabien Potencier <fabien@symfony.com>
17 class Twig_SimpleFunction
22 protected $arguments = array();
24 public function __construct($name, $callable, array $options = array())
27 $this->callable
= $callable;
28 $this->options
= array_merge(array(
29 'needs_environment' => false,
30 'needs_context' => false,
32 'is_safe_callback' => null,
33 'node_class' => 'Twig_Node_Expression_Function',
37 public function getName()
42 public function getCallable()
44 return $this->callable
;
47 public function getNodeClass()
49 return $this->options
['node_class'];
52 public function setArguments($arguments)
54 $this->arguments
= $arguments;
57 public function getArguments()
59 return $this->arguments
;
62 public function needsEnvironment()
64 return $this->options
['needs_environment'];
67 public function needsContext()
69 return $this->options
['needs_context'];
72 public function getSafe(Twig_Node
$functionArgs)
74 if (null !== $this->options
['is_safe']) {
75 return $this->options
['is_safe'];
78 if (null !== $this->options
['is_safe_callback']) {
79 return call_user_func($this->options
['is_safe_callback'], $functionArgs);