|
@@ -17,71 +17,37 @@ namespace Symfony\Framework\TwigBundle\Node;
|
|
|
* @subpackage Framework_TwigBundle
|
|
|
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
|
|
|
*/
|
|
|
-class HelperNode extends \Twig_Node implements \Twig_NodeListInterface
|
|
|
+class HelperNode extends \Twig_Node
|
|
|
{
|
|
|
- protected $name;
|
|
|
- protected $method;
|
|
|
- protected $arguments;
|
|
|
- protected $echo;
|
|
|
-
|
|
|
- public function __construct($name, $method, \Twig_NodeList $arguments, $echo, $lineno, $tag = null)
|
|
|
- {
|
|
|
- parent::__construct($lineno, $tag);
|
|
|
- $this->name = $name;
|
|
|
- $this->method = $method;
|
|
|
- $this->arguments = $arguments;
|
|
|
- $this->echo = $echo;
|
|
|
- }
|
|
|
-
|
|
|
- public function __toString()
|
|
|
- {
|
|
|
- return get_class($this).'('.$this->arguments.')';
|
|
|
- }
|
|
|
-
|
|
|
- public function getNodes()
|
|
|
- {
|
|
|
- return array($this->arguments);
|
|
|
- }
|
|
|
-
|
|
|
- public function setNodes(array $nodes)
|
|
|
+ public function __construct($name, $method, \Twig_Node $arguments = null, $echo, $lineno, $tag = null)
|
|
|
{
|
|
|
- $this->arguments = $nodes[0];
|
|
|
+ parent::__construct(array('arguments' => $arguments), array('name' => $name, 'method' => $method, 'echo' => $echo), $lineno, $tag);
|
|
|
}
|
|
|
|
|
|
public function compile($compiler)
|
|
|
{
|
|
|
- $compiler->addDebugInfo($this);
|
|
|
+ $compiler
|
|
|
+ ->addDebugInfo($this)
|
|
|
+ ->write('')
|
|
|
+ ;
|
|
|
|
|
|
- if ($this->echo) {
|
|
|
+ if ($this['echo']) {
|
|
|
$compiler->raw('echo ');
|
|
|
}
|
|
|
|
|
|
- $compiler->write('$context[\'_view\']->'.$this->name.'->'.$this->method.'(');
|
|
|
+ $compiler->raw('$context[\'_view\']->'.$this['name'].'->'.$this['method'].'(');
|
|
|
|
|
|
- $count = count($this->arguments->getNodes());
|
|
|
- foreach ($this->arguments->getNodes() as $i => $node) {
|
|
|
- $compiler->subcompile($node);
|
|
|
+ if (null !== $this->arguments) {
|
|
|
+ $count = count($this->arguments);
|
|
|
+ foreach ($this->arguments as $i => $node) {
|
|
|
+ $compiler->subcompile($node);
|
|
|
|
|
|
- if ($i !== $count - 1) {
|
|
|
- $compiler->raw(', ');
|
|
|
+ if ($i !== $count - 1) {
|
|
|
+ $compiler->raw(', ');
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
$compiler->raw(");\n");
|
|
|
}
|
|
|
-
|
|
|
- public function getName()
|
|
|
- {
|
|
|
- return $this->name;
|
|
|
- }
|
|
|
-
|
|
|
- public function getMethod()
|
|
|
- {
|
|
|
- return $this->method;
|
|
|
- }
|
|
|
-
|
|
|
- public function getArguments()
|
|
|
- {
|
|
|
- return $this->arguments;
|
|
|
- }
|
|
|
}
|