Add UIBlocks to twig (changed UIContentBlock params)

This commit is contained in:
Eric
2021-01-14 09:29:12 +01:00
parent bffb7b5eab
commit e51fd028fa
5 changed files with 95 additions and 19 deletions

View File

@@ -14,19 +14,24 @@ use Twig\Node\Node;
class UIContentBlockNode extends Node
{
public function __construct($sName, $sContainerClass, $oBody, $lineno = 0, $tag = null)
public function __construct($oParams, $oBody, $lineno = 0, $tag = null)
{
parent::__construct(['body' => $oBody], ['name' => $sName, 'container_class' => $sContainerClass], $lineno, $tag);
parent::__construct(['body' => $oBody], ['params' => $oParams], $lineno, $tag);
}
public function compile(Compiler $compiler)
{
$sBlockVar = UIBlockHelper::GetBlockVarName('oContentBlock');
$sName = empty($this->getAttribute('name')) ? 'null' : "'".$this->getAttribute('name')."'";
$sContainerClass = $this->getAttribute('container_class');
$oParams = $this->getAttribute('params');
$compiler
->addDebugInfo($this)
->write("\${$sBlockVar} = new Combodo\\iTop\\Application\\UI\\Base\\Layout\\UIContentBlock({$sName}, '{$sContainerClass}');\n")
->write("\$aParams = ")
->subcompile($oParams)
->raw(";\n")
->write("\$sId = \$aParams['id'] ?? null;\n")
->write("\$sContainerClass = \$aParams['container_class'] ?? '';\n")
->write("\${$sBlockVar} = new Combodo\\iTop\\Application\\UI\\Base\\Layout\\UIContentBlock(\$sId, \$sContainerClass);\n")
->write(UIBlockHelper::AddToParentBlock($sBlockVar))
->write(UIBlockHelper::PushParentBlock($sBlockVar))
->subcompile($this->getNode('body'))