vendor/twig/twig/src/Node/EmbedNode.php line 26

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