2024-05-12 18:38:33 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
namespace Modules\Plugins\Manifest;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @property string $label
|
|
|
|
* @property string $value
|
2024-12-10 15:57:06 +00:00
|
|
|
* @property string $hint
|
2024-05-12 18:38:33 +00:00
|
|
|
*/
|
|
|
|
class Option extends ManifestObject
|
|
|
|
{
|
2024-12-23 15:35:47 +00:00
|
|
|
public static array $validation_rules = [
|
2024-12-10 15:57:06 +00:00
|
|
|
'label' => 'required|string',
|
|
|
|
'value' => 'required|alpha_numeric_punct',
|
|
|
|
'description' => 'permit_empty|string',
|
2024-05-12 18:38:33 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
protected string $label;
|
|
|
|
|
|
|
|
protected string $value;
|
|
|
|
|
2024-12-10 15:57:06 +00:00
|
|
|
protected string $description = '';
|
|
|
|
|
|
|
|
public function getTranslated(string $i18nKey, string $property): string
|
|
|
|
{
|
|
|
|
$key = sprintf('%s.%s.%s', $i18nKey, $this->value, $property);
|
|
|
|
|
|
|
|
/** @var string $i18nField */
|
|
|
|
$i18nField = lang($key);
|
|
|
|
|
|
|
|
if ($this->{$property} === '' || $i18nField === $key) {
|
|
|
|
return esc($this->{$property});
|
|
|
|
}
|
|
|
|
|
|
|
|
return esc($i18nField);
|
|
|
|
}
|
2024-05-12 18:38:33 +00:00
|
|
|
}
|