PHP Class Piwik\Settings\Measurable\MeasurableSettings

Descendants of this class should implement the {@link init()} method and call the {@link makeSetting()} method for each of the measurable's settings. For an example, see the {@link Piwik\Plugins\ExampleSettingsPlugin\MeasurableSettings} plugin. $settingsProvider = new Piwik\Plugin\SettingsProvider(); // get this instance via dependency injection $measurableSettings = $settingProvider->getMeasurableSettings($yourPluginName, $idsite, $idType = null); $measurableSettings->yourSetting->getValue();
Inheritance: extends Piwik\Settings\Settings
Show file Open project: piwik/piwik Class Usage Examples

Protected Properties

Property Type Description
$idMeasurableType string
$idSite integer

Public Methods

Method Description
__construct ( integer $idSite, string | null $idMeasurableType = null ) Constructor.
save ( ) Saves (persists) the current measurable setting values in the database.

Protected Methods

Method Description
hasMeasurableType ( $typeId )
makeProperty ( $name, $defaultValue, $type, $configureCallback ) : MeasurableProperty
makeSetting ( string $name, mixed $defaultValue, string $type, Closure $fieldConfigCallback ) : MeasurableSetting Creates a new measurable setting.

Method Details

__construct() public method

Constructor.
public __construct ( integer $idSite, string | null $idMeasurableType = null )
$idSite integer If creating settings for a new site that is not created yet, use idSite = 0
$idMeasurableType string | null If null, idType will be detected from idSite

hasMeasurableType() protected method

protected hasMeasurableType ( $typeId )

makeProperty() protected method

protected makeProperty ( $name, $defaultValue, $type, $configureCallback ) : MeasurableProperty
$name
$defaultValue
$type
$configureCallback
return MeasurableProperty

makeSetting() protected method

Settings will be displayed in the UI depending on the order of makeSetting calls. This means you can define the order of the displayed settings by calling makeSetting first for more important settings.
protected makeSetting ( string $name, mixed $defaultValue, string $type, Closure $fieldConfigCallback ) : MeasurableSetting
$name string The name of the setting that shall be created
$defaultValue mixed The default value for this setting. Note the value will not be converted to the specified type.
$type string The PHP internal type the value of this setting should have. Use one of FieldConfig::TYPE_* constancts
$fieldConfigCallback Closure A callback method to configure the field that shall be displayed in the UI to define the value for this setting
return MeasurableSetting Returns an instance of the created measurable setting.

save() public method

Will trigger an event to notify plugins that a value has been changed.
public save ( )

Property Details

$idMeasurableType protected property

protected string $idMeasurableType
return string

$idSite protected property

protected int $idSite
return integer