You are here

public function Twig_Node_SandboxedPrint::compile in Translation template extractor 6.3

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

Compiles the node to PHP.

Parameters

Twig_Compiler $compiler A Twig_Compiler instance:

Overrides Twig_Node_Print::compile

File

vendor/Twig/Node/SandboxedPrint.php, line 34

Class

Twig_Node_SandboxedPrint
Twig_Node_SandboxedPrint adds a check for the __toString() method when the variable is an object and the sandbox is activated.

Code

public function compile(Twig_Compiler $compiler) {
  $compiler
    ->addDebugInfo($this)
    ->write('echo $this->env->getExtension(\'sandbox\')->ensureToStringAllowed(')
    ->subcompile($this
    ->getNode('expr'))
    ->raw(");\n");
}