N°1555: fixed a case where AttributeExternal field was pointing anything else than an ExternalKey and its label wouldn't show up on search criteria

This commit is contained in:
steffunky
2018-10-09 18:25:48 +02:00
parent 4c2be6b2c5
commit 3347d32f2a

View File

@@ -917,24 +917,35 @@ class ScalarExpression extends UnaryExpression
case ($oAttDef instanceof AttributeExternalField):
try
{
if ($this->GetValue() != 0)
$oFinalAttDef = $oAttDef->GetFinalAttDef();
if($oFinalAttDef instanceof AttributeExternalKey)
{
/** @var AttributeExternalKey $oAttDef */
$sTarget = $oAttDef->GetFinalAttDef()->GetTargetClass();
$oObj = MetaModel::GetObject($sTarget, $this->GetValue());
$aValue['label'] = $oObj->Get("friendlyname");
$aValue['value'] = $this->GetValue();
$aCriterion['values'] = array($aValue);
if ($this->GetValue() !== 0)
{
/** @var AttributeExternalKey $oFinalAttDef */
$sTarget = $oFinalAttDef->GetTargetClass();
$oObj = MetaModel::GetObject($sTarget, $this->GetValue());
$aValue['label'] = $oObj->Get("friendlyname");
$aValue['value'] = $this->GetValue();
}
else
{
$aValue['label'] = Dict::S('Enum:Undefined');
$aValue['value'] = $this->GetValue();
}
}
else
{
$aValue['label'] = Dict::S('Enum:Undefined');
$aValue['label'] = $this->GetValue();
$aValue['value'] = $this->GetValue();
$aCriterion['values'] = array($aValue);
}
} catch (Exception $e)
$aCriterion['values'] = array($aValue);
}
catch (Exception $e)
{
IssueLog::Error($e->getMessage());
}
catch (Exception $e)
{
IssueLog::Error($e->getMessage());
}