N°3917 Refactor algorithm to get object details semantic image icon in object's GetIcon method in order to propagate this feature anywhere where GetIcon is called

This commit is contained in:
Stephen Abello
2021-09-28 15:01:06 +02:00
parent ec47645ef7
commit 5680d9579c
3 changed files with 42 additions and 18 deletions

View File

@@ -204,20 +204,7 @@ class ObjectDetails extends Panel implements iKeyboardShortcut
// Default icon is the class icon
$sIconUrl = $oObject->GetIcon(false);
// Note: Class icons are a square image with no margin around, so they need to be zoomed out in the medallion
$sIconCoverMethod = static::ENUM_ICON_COVER_METHOD_ZOOMOUT;
// Use object image from semantic attribute only if it's not the default image
if (!$oObject->IsNew() && MetaModel::HasImageAttributeCode($this->sClassName)) {
$sImageAttCode = MetaModel::GetImageAttributeCode($this->sClassName);
if (!empty($sImageAttCode)) {
/** @var \ormDocument $oImage */
$oImage = $oObject->Get($sImageAttCode);
if (!$oImage->IsEmpty()) {
$sIconUrl = $oImage->GetDisplayURL($this->sClassName, $this->sObjectId, $sImageAttCode);
$sIconCoverMethod = static::ENUM_ICON_COVER_METHOD_COVER;
}
}
}
$sIconCoverMethod = $oObject->HasInstanceIcon() ? static::ENUM_ICON_COVER_METHOD_COVER : static::ENUM_ICON_COVER_METHOD_ZOOMOUT;
$this->SetIcon($sIconUrl, $sIconCoverMethod, true);
}