mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-01 14:38:47 +02:00
Add UIBlocks to twig (changed UIContentBlock params)
This commit is contained in:
@@ -29,8 +29,8 @@ class UIFieldSetNode extends Node
|
||||
->subcompile($oParams)
|
||||
->raw(";\n")
|
||||
->write("\$sLegend = \$aParams['legend'] ?? '';\n")
|
||||
->write("\$sName = \$aParams['value'] ?? null;\n")
|
||||
->write("\${$sBlockVar} = new Combodo\\iTop\\Application\\UI\\Base\\Component\\FieldSet\\FieldSet(\$sLegend, \$sName);\n")
|
||||
->write("\$sId = \$aParams['id'] ?? null;\n")
|
||||
->write("\${$sBlockVar} = new Combodo\\iTop\\Application\\UI\\Base\\Component\\FieldSet\\FieldSet(\$sLegend, \$sId);\n")
|
||||
->write(UIBlockHelper::AddToParentBlock($sBlockVar))
|
||||
->write(UIBlockHelper::PushParentBlock($sBlockVar))
|
||||
->subcompile($this->getNode('body'))
|
||||
|
||||
@@ -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'))
|
||||
|
||||
@@ -22,20 +22,14 @@ class UIContentBlockParser extends AbstractTokenParser
|
||||
$iLineno = $token->getLine();
|
||||
$oStream = $this->parser->getStream();
|
||||
|
||||
$sName = null;
|
||||
if ($oStream->test(Token::STRING_TYPE)) {
|
||||
$sName = $oStream->expect(Token::STRING_TYPE)->getValue();
|
||||
}
|
||||
$sContainerClass = '';
|
||||
if ($oStream->test(Token::STRING_TYPE)) {
|
||||
$sContainerClass = $oStream->expect(Token::STRING_TYPE)->getValue();
|
||||
}
|
||||
$oParams = $this->parser->getExpressionParser()->parseExpression();
|
||||
|
||||
$oStream->expect(Token::BLOCK_END_TYPE);
|
||||
|
||||
$oBody = $this->parser->subparse([$this, 'decideForEnd'], true);
|
||||
$oStream->expect(Token::BLOCK_END_TYPE);
|
||||
|
||||
return new UIContentBlockNode($sName, $sContainerClass, $oBody, $iLineno, $this->getTag());
|
||||
return new UIContentBlockNode($oParams, $oBody, $iLineno, $this->getTag());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -12,7 +12,7 @@ class UIBlockHelper
|
||||
{
|
||||
public static function PushParentBlock($sBlockVarName)
|
||||
{
|
||||
return "\$context['UIBlockParent'][] = \${$sBlockVarName};\n";
|
||||
return "array_push(\$context['UIBlockParent'], \${$sBlockVarName});\n";
|
||||
}
|
||||
|
||||
public static function PopParentBlock()
|
||||
|
||||
Reference in New Issue
Block a user