[ Index ]

PHP Cross Reference of phpBB-3.3.11-deutsch

title

Body

[close]

/phpbb/template/twig/node/ -> definenode.php (source)

   1  <?php
   2  /**
   3  *
   4  * This file is part of the phpBB Forum Software package.
   5  *
   6  * @copyright (c) phpBB Limited <https://www.phpbb.com>
   7  * @copyright Portions (c) 2009 Fabien Potencier, Armin Ronacher
   8  * @license GNU General Public License, version 2 (GPL-2.0)
   9  *
  10  * For full copyright and license information, please see
  11  * the docs/CREDITS.txt file.
  12  *
  13  */
  14  
  15  namespace phpbb\template\twig\node;
  16  
  17  class definenode extends \Twig\Node\Node
  18  {
  19  	public function __construct($capture, \Twig\Node\Node $name, \Twig\Node\Node $value, $lineno, $tag = null)
  20      {
  21          parent::__construct(array('name' => $name, 'value' => $value), array('capture' => $capture, 'safe' => false), $lineno, $tag);
  22      }
  23  
  24      /**
  25      * Compiles the node to PHP.
  26      *
  27      * @param \Twig\Compiler A Twig\Compiler instance
  28      */
  29  	public function compile(\Twig\Compiler $compiler)
  30      {
  31          $compiler->addDebugInfo($this);
  32  
  33          if ($this->getAttribute('capture'))
  34          {
  35              $compiler
  36                  ->write("ob_start();\n")
  37                  ->subcompile($this->getNode('value'))
  38              ;
  39  
  40              $compiler->write("\$value = ('' === \$value = ob_get_clean()) ? '' : new \Twig\Markup(\$value, \$this->env->getCharset());\n");
  41          }
  42          else
  43          {
  44              $compiler
  45                  ->write("\$value = ")
  46                  ->subcompile($this->getNode('value'))
  47                  ->raw(";\n")
  48              ;
  49          }
  50  
  51          $compiler
  52              ->write("\$context['definition']->set('")
  53              ->raw($this->getNode('name')->getAttribute('name'))
  54              ->raw("', \$value);\n")
  55          ;
  56      }
  57  }


Generated: Sat Nov 4 14:26:03 2023 Cross-referenced by PHPXref 0.7.1