mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-11 17:58:41 +00:00
Allow l11n type to reference the l11n.
This commit is contained in:
parent
0900e31d45
commit
06f1784418
|
|
@ -40,6 +40,14 @@ class BaseStringL11nType implements \JsonSerializable
|
||||||
*/
|
*/
|
||||||
public string $title = '';
|
public string $title = '';
|
||||||
|
|
||||||
|
/*
|
||||||
|
* String l11n
|
||||||
|
*
|
||||||
|
* @var string | BaseStringL11n
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public string | BaseStringL11n $l11n = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is the l11n type required for an item?
|
* Is the l11n type required for an item?
|
||||||
*
|
*
|
||||||
|
|
@ -72,6 +80,44 @@ class BaseStringL11nType implements \JsonSerializable
|
||||||
return $this->id;
|
return $this->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set l11n
|
||||||
|
*
|
||||||
|
* @param string|BaseStringL11n $l11n Tag article l11n
|
||||||
|
* @param string $lang Language
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public function setL11n(string | BaseStringL11n $l11n, string $lang = ISO639x1Enum::_EN) : void
|
||||||
|
{
|
||||||
|
if ($l11n instanceof BaseStringL11n) {
|
||||||
|
$this->l11n = $l11n;
|
||||||
|
} elseif (isset($this->l11n) && $this->l11n instanceof BaseStringL11n) {
|
||||||
|
$this->l11n->content = $l11n;
|
||||||
|
$this->l11n->setLanguage($lang);
|
||||||
|
} else {
|
||||||
|
$this->l11n = new BaseStringL11n();
|
||||||
|
$this->l11n->content = $l11n;
|
||||||
|
$this->l11n->setLanguage($lang);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public function getL11n() : string
|
||||||
|
{
|
||||||
|
if (!isset($this->l11n)) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->l11n instanceof BaseStringL11n ? $this->l11n->content : $this->l11n;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user