Improved Plugin Property handling

This commit is contained in:
the-djmaze 2022-11-10 12:40:26 +01:00
parent cc6a4c4de9
commit 364947d1f9
2 changed files with 14 additions and 36 deletions

View file

@ -13,11 +13,12 @@ class Plugin extends \RainLoop\Config\AbstractConfig
{
if (\count($aMap)) {
$aResultMap = array();
foreach ($aMap as /* @var $oProperty \RainLoop\Plugins\Property */ $oProperty) {
if ($oProperty) {
$mValue = $oProperty->DefaultValue();
$sValue = \is_array($mValue) && isset($mValue[0]) ? $mValue[0] : $mValue;
$aResultMap[$oProperty->Name()] = array($sValue, '');
foreach ($aMap as $oProperty) {
if ($oProperty instanceof \RainLoop\Plugins\Property) {
$aResultMap[$oProperty->Name()] = array(
$oProperty->DefaultValue(),
''
);
}
}
@ -28,6 +29,7 @@ class Plugin extends \RainLoop\Config\AbstractConfig
}
}
// parent::__construct('plugin-'.$sPluginName.'.ini', '; SnappyMail plugin ('.$sPluginName.')');
parent::__construct('plugin-'.$sPluginName.'.json');
}

View file

@ -4,55 +4,31 @@ namespace RainLoop\Plugins;
class Property implements \JsonSerializable
{
/**
* @var string
*/
private $sName;
private string $sName;
/**
* @var mixed
*/
private $mValue;
/**
* @var string
*/
private $sLabel;
private string $sLabel = '';
/**
* @var string
*/
private $sDesc;
private string $sDesc = '';
/**
* @var int
*/
private $iType;
private int $iType = \RainLoop\Enumerations\PluginPropertyType::STRING;
/**
* @var bool
*/
private $bAllowedInJs;
private bool $bAllowedInJs = false;
/**
* @var mixed
*/
private $mDefaultValue;
private $mDefaultValue = '';
/**
* @var string
*/
private $sPlaceholder;
private string $sPlaceholder = '';
function __construct(string $sName)
{
$this->sName = $sName;
$this->iType = \RainLoop\Enumerations\PluginPropertyType::STRING;
$this->mDefaultValue = '';
$this->sLabel = '';
$this->sDesc = '';
$this->bAllowedInJs = false;
$this->sPlaceholder = '';
}
public static function NewInstance(string $sName) : self