*/ class Twig_Node_SandboxedPrint extends Twig_Node_Print { public function __construct(Twig_Node_Print $node) { parent::__construct($node->getNode('expr'), $node->getLine(), $node->getNodeTag()); } /** * Compiles the node to PHP. * * @param Twig_Compiler A Twig_Compiler instance */ public function compile($compiler) { $compiler ->addDebugInfo($this) ->write('if ($this->env->hasExtension(\'sandbox\') && is_object(') ->subcompile($this->getNode('expr')) ->raw(')) {'."\n") ->indent() ->write('$this->env->getExtension(\'sandbox\')->checkMethodAllowed(') ->subcompile($this->getNode('expr')) ->raw(', \'__toString\');'."\n") ->outdent() ->write('}'."\n") ; parent::compile($compiler); } }