vendor/twig/twig/src/Node/Expression/ParentExpression.php line 24

Open in your IDE?
  1. <?php
  2. /*
  3. * This file is part of Twig.
  4. *
  5. * (c) Fabien Potencier
  6. * (c) Armin Ronacher
  7. *
  8. * For the full copyright and license information, please view the LICENSE
  9. * file that was distributed with this source code.
  10. */
  11. namespace Twig\Node\Expression;
  12. use Twig\Compiler;
  13. /**
  14. * Represents a parent node.
  15. *
  16. * @author Fabien Potencier <fabien@symfony.com>
  17. */
  18. class ParentExpression extends AbstractExpression
  19. {
  20. public function __construct(string $name, int $lineno, string $tag = null)
  21. {
  22. parent::__construct([], ['output' => false, 'name' => $name], $lineno, $tag);
  23. }
  24. public function compile(Compiler $compiler)
  25. {
  26. if ($this->getAttribute('output')) {
  27. $compiler
  28. ->addDebugInfo($this)
  29. ->write('$this->displayParentBlock(')
  30. ->string($this->getAttribute('name'))
  31. ->raw(", \$context, \$blocks);\n")
  32. ;
  33. } else {
  34. $compiler
  35. ->raw('$this->renderParentBlock(')
  36. ->string($this->getAttribute('name'))
  37. ->raw(', $context, $blocks)')
  38. ;
  39. }
  40. }
  41. }
  42. class_alias('Twig\Node\Expression\ParentExpression', 'Twig_Node_Expression_Parent');