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(string $name, int $index, ?AbstractExpression $variables, bool $only, bool $ignoreMissing, int $lineno, string $tag = null) 27 { 28 parent::__construct(new ConstantExpression('not_used', $lineno), $variables, $only, $ignoreMissing, $lineno, $tag); 29 30 $this->setAttribute('name', $name); 31 $this->setAttribute('index', $index); 32 } 33 34 protected function addGetTemplate(Compiler $compiler) 35 { 36 $compiler 37 ->write('$this->loadTemplate(') 38 ->string($this->getAttribute('name')) 39 ->raw(', ') 40 ->repr($this->getTemplateName()) 41 ->raw(', ') 42 ->repr($this->getTemplateLine()) 43 ->raw(', ') 44 ->string($this->getAttribute('index')) 45 ->raw(')') 46 ; 47 } 48} 49 50class_alias('Twig\Node\EmbedNode', 'Twig_Node_Embed'); 51