2014-05-14 23:24:20 +10:00
|
|
|
<?php namespace Cms\Twig;
|
|
|
|
|
|
|
|
use Twig_Node;
|
|
|
|
use Twig_Compiler;
|
|
|
|
use Twig_NodeInterface;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Represents a put node
|
|
|
|
*
|
|
|
|
* @package october\cms
|
|
|
|
* @author Alexey Bobkov, Samuel Georges
|
|
|
|
*/
|
|
|
|
class PutNode extends Twig_Node
|
|
|
|
{
|
2014-09-06 17:10:52 +10:00
|
|
|
public function __construct(Twig_NodeInterface $body, $name, $endType, $lineno, $tag = 'put')
|
2014-05-14 23:24:20 +10:00
|
|
|
{
|
2014-09-06 17:10:52 +10:00
|
|
|
parent::__construct(['body' => $body], ['name' => $name, 'endType' => $endType], $lineno, $tag);
|
2014-05-14 23:24:20 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Compiles the node to PHP.
|
|
|
|
*
|
2014-05-17 18:08:01 +02:00
|
|
|
* @param Twig_Compiler $compiler A Twig_Compiler instance
|
2014-05-14 23:24:20 +10:00
|
|
|
*/
|
|
|
|
public function compile(Twig_Compiler $compiler)
|
|
|
|
{
|
|
|
|
$compiler
|
|
|
|
->addDebugInfo($this)
|
|
|
|
->write("echo \$this->env->getExtension('CMS')->startBlock(")
|
|
|
|
->raw("'".$this->getAttribute('name')."'")
|
|
|
|
->write(");\n")
|
|
|
|
;
|
|
|
|
|
2014-09-06 17:10:52 +10:00
|
|
|
$isOverwrite = strtolower($this->getAttribute('endType')) == 'overwrite';
|
|
|
|
|
2014-05-14 23:24:20 +10:00
|
|
|
$compiler->subcompile($this->getNode('body'));
|
|
|
|
|
|
|
|
$compiler
|
|
|
|
->addDebugInfo($this)
|
2014-09-06 17:10:52 +10:00
|
|
|
->write("echo \$this->env->getExtension('CMS')->endBlock(")
|
|
|
|
->raw($isOverwrite ? 'false' : 'true')
|
|
|
|
->write(");\n")
|
2014-10-11 01:42:04 +02:00
|
|
|
;
|
2014-05-14 23:24:20 +10:00
|
|
|
}
|
2014-10-11 01:42:04 +02:00
|
|
|
}
|