ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
Function.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 
12 @trigger_error('The Twig_Function class is deprecated since version 1.12 and will be removed in 2.0. Use Twig_SimpleFunction instead.', E_USER_DEPRECATED);
13 
24 {
25  protected $options;
26  protected $arguments = array();
27 
28  public function __construct(array $options = array())
29  {
30  $this->options = array_merge(array(
31  'needs_environment' => false,
32  'needs_context' => false,
33  'callable' => null,
34  ), $options);
35  }
36 
37  public function setArguments($arguments)
38  {
39  $this->arguments = $arguments;
40  }
41 
42  public function getArguments()
43  {
44  return $this->arguments;
45  }
46 
47  public function needsEnvironment()
48  {
49  return $this->options['needs_environment'];
50  }
51 
52  public function needsContext()
53  {
54  return $this->options['needs_context'];
55  }
56 
57  public function getSafe(Twig_Node $functionArgs)
58  {
59  if (isset($this->options['is_safe'])) {
60  return $this->options['is_safe'];
61  }
62 
63  if (isset($this->options['is_safe_callback'])) {
64  return call_user_func($this->options['is_safe_callback'], $functionArgs);
65  }
66 
67  return array();
68  }
69 
70  public function getCallable()
71  {
72  return $this->options['callable'];
73  }
74 }
Represents a template function.
Definition: Function.php:23
Represents a node in the AST.
Definition: Node.php:18
__construct(array $options=array())
Definition: Function.php:28
getSafe(Twig_Node $functionArgs)
Definition: Function.php:57
needsEnvironment()
Definition: Function.php:47
Represents a template function.
Create styles array
The data for the language used.
Represents a callable template function.
setArguments($arguments)
Definition: Function.php:37