1<?php
2
3/*
4 * This file is part of Twig.
5 *
6 * (c) Fabien Potencier
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Twig\Node;
13
14use Twig\Compiler;
15use Twig\Node\Expression\AbstractExpression;
16use Twig\Node\Expression\ConstantExpression;
17
18/**
19 * Represents an embed node.
20 *
21 * @author Fabien Potencier <fabien@symfony.com>
22 */
23class EmbedNode extends IncludeNode
24{
25    // we don't inject the module to avoid node visitors to traverse it twice (as it will be already visited in the main module)
26    public function __construct($name, $index, AbstractExpression $variables = null, $only = false, $ignoreMissing = false, $lineno, $tag = null)
27    {
28        parent::__construct(new ConstantExpression('not_used', $lineno), $variables, $only, $ignoreMissing, $lineno, $tag);
29
30        $this->setAttribute('name', $name);
31        // to be removed in 2.0, used name instead
32        $this->setAttribute('filename', $name);
33        $this->setAttribute('index', $index);
34    }
35
36    protected function addGetTemplate(Compiler $compiler)
37    {
38        $compiler
39            ->write('$this->loadTemplate(')
40            ->string($this->getAttribute('name'))
41            ->raw(', ')
42            ->repr($this->getTemplateName())
43            ->raw(', ')
44            ->repr($this->getTemplateLine())
45            ->raw(', ')
46            ->string($this->getAttribute('index'))
47            ->raw(')')
48        ;
49    }
50}
51
52class_alias('Twig\Node\EmbedNode', 'Twig_Node_Embed');
53