ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
SimpleFunction.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of Twig.
5  *
6  * (c) Fabien Potencier
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11 
20 {
21  protected $name;
22  protected $callable;
23  protected $options;
24  protected $arguments = array();
25 
26  public function __construct($name, $callable, array $options = array())
27  {
28  $this->name = $name;
29  $this->callable = $callable;
30  $this->options = array_merge(array(
31  'needs_environment' => false,
32  'needs_context' => false,
33  'is_variadic' => false,
34  'is_safe' => null,
35  'is_safe_callback' => null,
36  'node_class' => 'Twig_Node_Expression_Function',
37  'deprecated' => false,
38  'alternative' => null,
39  ), $options);
40  }
41 
42  public function getName()
43  {
44  return $this->name;
45  }
46 
47  public function getCallable()
48  {
49  return $this->callable;
50  }
51 
52  public function getNodeClass()
53  {
54  return $this->options['node_class'];
55  }
56 
57  public function setArguments($arguments)
58  {
59  $this->arguments = $arguments;
60  }
61 
62  public function getArguments()
63  {
64  return $this->arguments;
65  }
66 
67  public function needsEnvironment()
68  {
69  return $this->options['needs_environment'];
70  }
71 
72  public function needsContext()
73  {
74  return $this->options['needs_context'];
75  }
76 
77  public function getSafe(Twig_Node $functionArgs)
78  {
79  if (null !== $this->options['is_safe']) {
80  return $this->options['is_safe'];
81  }
82 
83  if (null !== $this->options['is_safe_callback']) {
84  return call_user_func($this->options['is_safe_callback'], $functionArgs);
85  }
86 
87  return array();
88  }
89 
90  public function isVariadic()
91  {
92  return $this->options['is_variadic'];
93  }
94 
95  public function isDeprecated()
96  {
97  return (bool) $this->options['deprecated'];
98  }
99 
100  public function getDeprecatedVersion()
101  {
102  return $this->options['deprecated'];
103  }
104 
105  public function getAlternative()
106  {
107  return $this->options['alternative'];
108  }
109 }
110 
111 class_alias('Twig_SimpleFunction', 'Twig\TwigFunction', false);
Represents a template function.
Represents a node in the AST.
Definition: Node.php:18
__construct($name, $callable, array $options=array())
setArguments($arguments)
getSafe(Twig_Node $functionArgs)
Create styles array
The data for the language used.