You are here

public function Twig_Node_Expression_Test::compile in Translation template extractor 6.3

Same name and namespace in other branches
  1. 7.3 vendor/Twig/Node/Expression/Test.php \Twig_Node_Expression_Test::compile()

Compiles the node to PHP.

Parameters

Twig_Compiler $compiler A Twig_Compiler instance:

Overrides Twig_Node::compile

7 methods override Twig_Node_Expression_Test::compile()
Twig_Node_Expression_Test_Constant::compile in vendor/Twig/Node/Expression/Test/Constant.php
Compiles the node to PHP.
Twig_Node_Expression_Test_Defined::compile in vendor/Twig/Node/Expression/Test/Defined.php
Compiles the node to PHP.
Twig_Node_Expression_Test_Divisibleby::compile in vendor/Twig/Node/Expression/Test/Divisibleby.php
Compiles the node to PHP.
Twig_Node_Expression_Test_Even::compile in vendor/Twig/Node/Expression/Test/Even.php
Compiles the node to PHP.
Twig_Node_Expression_Test_Null::compile in vendor/Twig/Node/Expression/Test/Null.php
Compiles the node to PHP.

... See full list

File

vendor/Twig/Node/Expression/Test.php, line 18

Class

Twig_Node_Expression_Test

Code

public function compile(Twig_Compiler $compiler) {
  $name = $this
    ->getAttribute('name');
  $test = $compiler
    ->getEnvironment()
    ->getTest($name);
  $this
    ->setAttribute('name', $name);
  $this
    ->setAttribute('type', 'test');
  $this
    ->setAttribute('thing', $test);
  if ($test instanceof Twig_TestCallableInterface || $test instanceof Twig_SimpleTest) {
    $this
      ->setAttribute('callable', $test
      ->getCallable());
  }
  $this
    ->compileCallable($compiler);
}