Piwik\Settings\
Base setting type class.
The class defines the following methods:
__construct()
— Constructor.getName()
— Get the name of the setting.getType()
— Get the PHP type of the setting.getDefaultValue()
setDefaultValue()
— Sets/overwrites the current default valuesetIsWritableByCurrentUser()
— Set whether setting is writable or not.isWritableByCurrentUser()
— Returns true
if this setting is writable for the current user, false
if otherwise.save()
— Saves (persists) the value for this setting in the database if a value has been actually set.getValue()
— Returns the previously persisted setting value.setValue()
— Sets and persists this setting's value overwriting any existing value.__construct()
Constructor.
$name
(string
) —
The setting's persisted name. Only alphanumeric characters are allowed, eg, 'refreshInterval'
.$defaultValue
(mixed
) —
Default value for this setting if no value was specified.$type
(string
) —
Eg an array, int, ... see SettingConfig::TYPE_* constants$pluginName
(string
) —
The name of the plugin the setting belongs togetName()
Get the name of the setting.
string
value.getType()
Get the PHP type of the setting.
string
value.getDefaultValue()
mixed
value.setDefaultValue()
Sets/overwrites the current default value
It accepts the following parameter(s):
$defaultValue
(string
) —It does not return anything or a mixed result.
setIsWritableByCurrentUser()
Set whether setting is writable or not. For example to hide setting from the UI set it to false.
It accepts the following parameter(s):
$isWritable
(bool
) —It does not return anything or a mixed result.
isWritableByCurrentUser()
Returns true
if this setting is writable for the current user, false
if otherwise. In case it returns
writable for the current user it will be visible in the Plugin settings UI.
bool
value.save()
Saves (persists) the value for this setting in the database if a value has been actually set.
getValue()
Returns the previously persisted setting value. If no value was set, the default value is returned.
mixed
value.setValue()
Sets and persists this setting's value overwriting any existing value.
Before a value is actually set it will be made sure the current user is allowed to change the value. The value will be first validated either via a system built-in validate method or via a set FieldConfig::$validate custom method. Afterwards the value will be transformed via a possibly specified FieldConfig::$transform method. Before storing the actual value, the value will be converted to the actually specified $type.
It accepts the following parameter(s):
$value
(mixed
) —It does not return anything or a mixed result.
Exception
— If the current user is not allowed to change the value of this setting.