mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-19 16:48:42 +02:00
N°5375 - XML custo on Semantic field with hierarchy, breaks at compilation (#323)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user