|
@@ -18,9 +18,9 @@ namespace Symfony\Bundle\TwigBundle\Node;
|
|
*/
|
|
*/
|
|
class TransNode extends \Twig_Node
|
|
class TransNode extends \Twig_Node
|
|
{
|
|
{
|
|
- public function __construct(\Twig_NodeInterface $body, \Twig_NodeInterface $domain, \Twig_Node_Expression $count = null, \Twig_Node_Expression $vars = null, $lineno, $tag = null)
|
|
|
|
|
|
+ public function __construct(\Twig_NodeInterface $body, \Twig_NodeInterface $domain, \Twig_Node_Expression $count = null, \Twig_Node_Expression $vars = null, $isSimple, $lineno, $tag = null)
|
|
{
|
|
{
|
|
- parent::__construct(array('count' => $count, 'body' => $body, 'domain' => $domain, 'vars' => $vars), array(), $lineno, $tag);
|
|
|
|
|
|
+ parent::__construct(array('count' => $count, 'body' => $body, 'domain' => $domain, 'vars' => $vars), array('is_simple' => $isSimple), $lineno, $tag);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -32,7 +32,7 @@ class TransNode extends \Twig_Node
|
|
{
|
|
{
|
|
$compiler->addDebugInfo($this);
|
|
$compiler->addDebugInfo($this);
|
|
|
|
|
|
- if ($this->isSimpleString($this->body)) {
|
|
|
|
|
|
+ if ($this['is_simple']) {
|
|
list($msg, $vars) = $this->compileString($this->body);
|
|
list($msg, $vars) = $this->compileString($this->body);
|
|
} else {
|
|
} else {
|
|
$msg = $this->body;
|
|
$msg = $this->body;
|
|
@@ -102,21 +102,4 @@ class TransNode extends \Twig_Node
|
|
|
|
|
|
return array(new \Twig_Node(array(new \Twig_Node_Expression_Constant(trim($msg), $node->getLine()))), $vars);
|
|
return array(new \Twig_Node(array(new \Twig_Node_Expression_Constant(trim($msg), $node->getLine()))), $vars);
|
|
}
|
|
}
|
|
-
|
|
|
|
- protected function isSimpleString(\Twig_NodeInterface $body)
|
|
|
|
- {
|
|
|
|
- foreach ($body as $i => $node) {
|
|
|
|
- if (
|
|
|
|
- $node instanceof \Twig_Node_Text
|
|
|
|
- ||
|
|
|
|
- ($node instanceof \Twig_Node_Print && $node->expr instanceof \Twig_Node_Expression_Name)
|
|
|
|
- ) {
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return false;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return true;
|
|
|
|
- }
|
|
|
|
}
|
|
}
|