N°4175 - Adding a lifecycle to an existing class fails on setup (using xml version < 3.0)

This commit is contained in:
Eric
2021-07-28 13:30:39 +02:00
parent 14a5f87d62
commit 3a988ab499
3 changed files with 19 additions and 0 deletions

View File

@@ -785,6 +785,12 @@ class iTopDesignFormat
if ($oFieldsSemanticNodeList->length > 0) {
$oSemanticNode = $oFieldsSemanticNodeList->item(0);
} else {
if (is_null($oPropertiesNode)) {
// No properties node found, create it
$oClassNode = $oXPath->query("../..", $oNode)->item(0);
$oPropertiesNode = $oClassNode->ownerDocument->createElement("properties");
$oClassNode->appendChild($oPropertiesNode);
}
$oSemanticNode = $oPropertiesNode->ownerDocument->createElement("fields_semantic");
$oPropertiesNode->appendChild($oSemanticNode);
}

View File

@@ -28,6 +28,14 @@
</properties>
<lifecycle/>
</class>
<class id="ClassWithLifecycleNoProperties">
<lifecycle/>
<properties>
<fields_semantic>
<state_attribute>foo</state_attribute>
</fields_semantic>
</properties>
</class>
<class id="OtherClass">
<properties>
<style>

View File

@@ -28,6 +28,11 @@
<attribute>foo</attribute>
</lifecycle>
</class>
<class id="ClassWithLifecycleNoProperties">
<lifecycle>
<attribute>foo</attribute>
</lifecycle>
</class>
<class id="OtherClass">
<properties>
<icon revisionid="2" _delta="redefine">