[TwigBundle] updated the bundle to take advantage of the latest Twig version

This commit is contained in:
Fabien Potencier 2010-06-10 19:19:00 +02:00
parent 77d3f924df
commit 075edbc3b7

View File

@ -55,40 +55,14 @@ class HelperTokenParser extends \Twig_SimpleTokenParser
protected function getNode(array $values, $line) protected function getNode(array $values, $line)
{ {
$helper = new \Twig_Node_Expression_GetAttr( return $this->output(
new \Twig_Node_Expression_Name('_view', $line), $this->markAsSafe(
new \Twig_Node_Expression_Constant($this->helper, $line), $this->getAttribute(
new \Twig_Node(), $this->getAttribute('_view', $this->helper),
\Twig_Node_Expression_GetAttr::TYPE_ANY, $this->method,
$line $this->getNodeValues($values)
)
)
); );
$call = new \Twig_Node_Expression_GetAttr(
$helper,
new \Twig_Node_Expression_Constant($this->method, $line),
new \Twig_Node($this->getArguments($values)),
\Twig_Node_Expression_GetAttr::TYPE_METHOD,
$line
);
$safe = new \Twig_Node_Expression_Filter(
$call,
new \Twig_Node(array(new \Twig_Node_Expression_Constant('safe', $line), new \Twig_Node())),
$line
);
return new \Twig_Node_Print($safe, $line);
}
protected function getArguments(array $values)
{
$arguments = array();
foreach ($values as $value) {
if ($value instanceof \Twig_NodeInterface) {
$arguments[] = $value;
}
}
return $arguments;
} }
} }