vendor/twig/twig/src/Node/BlockNode.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;
  12. use Twig\Compiler;
  13. /**
  14.  * Represents a block node.
  15.  *
  16.  * @author Fabien Potencier <fabien@symfony.com>
  17.  */
  18. class BlockNode extends Node
  19. {
  20.     public function __construct(string $nameNode $bodyint $linenostring $tag null)
  21.     {
  22.         parent::__construct(['body' => $body], ['name' => $name], $lineno$tag);
  23.     }
  24.     public function compile(Compiler $compiler): void
  25.     {
  26.         $compiler
  27.             ->addDebugInfo($this)
  28.             ->write(sprintf("public function block_%s(\$context, array \$blocks = [])\n"$this->getAttribute('name')), "{\n")
  29.             ->indent()
  30.             ->write("\$macros = \$this->macros;\n")
  31.         ;
  32.         $compiler
  33.             ->subcompile($this->getNode('body'))
  34.             ->outdent()
  35.             ->write("}\n\n")
  36.         ;
  37.     }
  38. }