You are here

public function Twig_Node_Expression_Function::compile in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/twig/twig/lib/Twig/Node/Expression/Function.php \Twig_Node_Expression_Function::compile()

Compiles the node to PHP.

Parameters

Twig_Compiler $compiler A Twig_Compiler instance:

Overrides Twig_Node::compile

File

vendor/twig/twig/lib/Twig/Node/Expression/Function.php, line 18

Class

Twig_Node_Expression_Function

Code

public function compile(Twig_Compiler $compiler) {
  $name = $this
    ->getAttribute('name');
  $function = $compiler
    ->getEnvironment()
    ->getFunction($name);
  $this
    ->setAttribute('name', $name);
  $this
    ->setAttribute('type', 'function');
  $this
    ->setAttribute('thing', $function);
  $this
    ->setAttribute('needs_environment', $function
    ->needsEnvironment());
  $this
    ->setAttribute('needs_context', $function
    ->needsContext());
  $this
    ->setAttribute('arguments', $function
    ->getArguments());
  if ($function instanceof Twig_FunctionCallableInterface || $function instanceof Twig_SimpleFunction) {
    $this
      ->setAttribute('callable', $function
      ->getCallable());
  }
  if ($function instanceof Twig_SimpleFunction) {
    $this
      ->setAttribute('is_variadic', $function
      ->isVariadic());
  }
  $this
    ->compileCallable($compiler);
}