[TwigBundle] updated nodes for the latest version of Twig

This commit is contained in:
Fabien Potencier 2010-10-02 09:39:29 +02:00
parent 8e654e8f9e
commit 77125288e7

View File

@ -32,14 +32,14 @@ class TransNode extends \Twig_Node
{ {
$compiler->addDebugInfo($this); $compiler->addDebugInfo($this);
if ($this['is_simple']) { if ($this->getAttribute('is_simple')) {
list($msg, $vars) = $this->compileString($this->body); list($msg, $vars) = $this->compileString($this->getNode('body'));
} else { } else {
$msg = $this->body; $msg = $this->getNode('body');
$vars = $this->vars; $vars = $this->getNode('vars');
} }
$method = null === $this->count ? 'trans' : 'transChoice'; $method = null === $this->getNode('count') ? 'trans' : 'transChoice';
$compiler $compiler
->write('echo $this->env->getExtension(\'translator\')->getTranslator()->'.$method.'(') ->write('echo $this->env->getExtension(\'translator\')->getTranslator()->'.$method.'(')
@ -48,9 +48,9 @@ class TransNode extends \Twig_Node
$compiler->raw(', '); $compiler->raw(', ');
if (null !== $this->count) { if (null !== $this->getNode('count')) {
$compiler $compiler
->subcompile($this->count) ->subcompile($this->getNode('count'))
->raw(', ') ->raw(', ')
; ;
} }
@ -74,7 +74,7 @@ class TransNode extends \Twig_Node
$compiler $compiler
->raw("), ") ->raw("), ")
->subcompile($this->domain) ->subcompile($this->getNode('domain'))
->raw(");\n") ->raw(");\n")
; ;
} }
@ -89,14 +89,14 @@ class TransNode extends \Twig_Node
$vars = array(); $vars = array();
foreach ($body as $node) { foreach ($body as $node) {
if ($node instanceof \Twig_Node_Print) { if ($node instanceof \Twig_Node_Print) {
$n = $node->expr; $n = $node->getNode('expr');
while ($n instanceof \Twig_Node_Expression_Filter) { while ($n instanceof \Twig_Node_Expression_Filter) {
$n = $n->node; $n = $n->getNode('node');
} }
$msg .= sprintf('{{ %s }}', $n['name']); $msg .= sprintf('{{ %s }}', $n->getAttribute('name'));
$vars[] = new \Twig_Node_Expression_Name($n['name'], $n->getLine()); $vars[] = new \Twig_Node_Expression_Name($n->getAttribute('name'), $n->getLine());
} else { } else {
$msg .= $node['data']; $msg .= $node->getAttribute('data');
} }
} }