ormStyle: Fix icon URL including the app. root in the MetaModel to ease usage with load balancers

This commit is contained in:
Molkobain
2021-09-25 14:38:10 +02:00
parent 4d8ac5fee5
commit ca7f6362bf
4 changed files with 172 additions and 21 deletions

View File

@@ -21,7 +21,7 @@ class ormStyle
protected $sAltStyleClass;
/** @var string */
protected $sDecorationClasses;
/** @var string */
/** @var string Relative path (from current environment) to the icon */
protected $sIcon;
/**
@@ -41,7 +41,7 @@ class ormStyle
$this->sStyleClass = $sStyleClass;
$this->sAltStyleClass = $sAltStyleClass;
$this->sDecorationClasses = $sDecorationClasses;
$this->sIcon = $sIcon;
$this->SetIcon($sIcon);
}
/**
@@ -139,14 +139,6 @@ class ormStyle
return $this;
}
/**
* @return string
*/
public function GetIcon(): ?string
{
return $this->sIcon;
}
/**
* @param string|null $sIcon
*
@@ -154,8 +146,30 @@ class ormStyle
*/
public function SetIcon(?string $sIcon)
{
$this->sIcon = $sIcon;
$this->sIcon = (strlen($sIcon) === 0) ? null : $sIcon;
return $this;
}
/**
* @see static::$sIcon
* @return string|null Relative path (from the current environment) of the icon
*/
public function GetIconAsRelPath(): ?string
{
return $this->sIcon;
}
/**
* @see static::$sIcon
* @return string|null Absolute URL of the icon
* @throws \Exception
*/
public function GetIconAsAbsUrl(): ?string
{
if (is_null($this->sIcon)) {
return null;
}
return utils::GetAbsoluteUrlModulesRoot().$this->sIcon;
}
}