N°5375 - XML custo on Semantic field with hierarchy, breaks at compilation (#323)

This commit is contained in:
Eric Espié
2022-08-09 17:37:01 +02:00
committed by GitHub
parent 43b49034df
commit 69749a5cbe

View File

@@ -2012,7 +2012,11 @@ EOF
// Note: We can't use ModelFactory::GetField() as the current clas doesn't seem to be loaded yet.
$oField = $this->oFactory->GetNodes('field[@id="'.$sStateAttCode.'"]', $oFields)->item(0);
if ($oField == null) {
throw new DOMFormatException("Non existing attribute '$sStateAttCode'", null, null, $oStateAttribute);
// Search field in parent class
$oField = $this->GetFieldInParentClasses($oClass, $sStateAttCode);
if ($oField == null) {
throw new DOMFormatException("Non existing attribute '$sStateAttCode'", null, null, $oStateAttribute);
}
}
$oValues = $oField->GetUniqueElement('values');
$oValueNodes = $oValues->getElementsByTagName('value');
@@ -3736,4 +3740,19 @@ EOF;
return $sValue;
}
private function GetFieldInParentClasses($oClass, $sAttCode)
{
$sParentClass = $oClass->GetChildText('parent', 'DBObject');
if ($sParentClass != 'DBObject') {
$oParent = $this->oFactory->GetClass($sParentClass);
$oParentFields = $oParent->GetOptionalElement('fields');
$oField = $this->oFactory->GetNodes('field[@id="'.$sAttCode.'"]', $oParentFields)->item(0);
if ($oField != null) {
return $oField;
}
return $this->GetFieldInParentClasses($oParent, $sAttCode);
}
return null;
}
}