N°9066 - Serialization/Unserialization from XML to Forms

This commit is contained in:
Eric Espie
2026-01-07 14:29:08 +01:00
parent efb1bd765b
commit 154fb5c737
23 changed files with 553 additions and 112 deletions

View File

@@ -37,7 +37,7 @@ class PropertyType
$sDefinitionNodeType = $oDefinitionNode->getAttribute('xsi:type');
if (!is_a($sDefinitionNodeType, AbstractValueType::class, true)) {
throw new PropertyTypeException('Unsupported type '.json_encode($sDefinitionNodeType).' in ');
throw new PropertyTypeException('Unsupported xsi:type '.json_encode($sDefinitionNodeType), $oDomNode);
}
$this->oValueType = new $sDefinitionNodeType();
@@ -50,18 +50,11 @@ class PropertyType
$aPHPFragments = [];
if ($this->oValueType->IsLeaf()) {
$sFormBlockClass = $this->oValueType->GetFormBlockClass();
$sLocalPHP = <<<PHP
class FormFor__$this->sId extends Combodo\iTop\Forms\Block\Base\FormBlock
class FormFor__$this->sId extends $sFormBlockClass
{
protected function BuildForm(): void
{
PHP;
$sLocalPHP .= "\n".$this->oValueType->ToPHPFormBlock($aPHPFragments);
$sLocalPHP .= <<<PHP
}
}
PHP;
$aPHPFragments[] = $sLocalPHP;
@@ -76,4 +69,14 @@ PHP;
{
return $this->sParentType;
}
public function SerializeToDOMNode(mixed $value, DesignElement$oDOMNode): void
{
$this->oValueType->SerializeToDOMNode($value, $oDOMNode);
}
public function UnserializeFromDOMNode(DesignElement $oDOMNode): mixed
{
return $this->oValueType->UnserializeFromDOMNode($oDOMNode);
}
}