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

View file

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