Class pheme\settings\components\Settings

Inheritancepheme\settings\components\Settings » yii\base\Component

Public Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
$cache \yii\caching\Cache|string The cache object or the application component ID of the cache object. pheme\settings\components\Settings
$cacheKey string Cache key pheme\settings\components\Settings
$frontCache \yii\caching\Cache|string The front cache object or the application component ID of the front cache object. pheme\settings\components\Settings
$modelClass string Settings model. pheme\settings\components\Settings

Public Methods

Hide inherited methods

MethodDescriptionDefined By
activate() Activates a setting pheme\settings\components\Settings
clearCache() Clears the settings cache on demand. pheme\settings\components\Settings
deactivate() Deactivates a setting pheme\settings\components\Settings
delete() Deletes a setting pheme\settings\components\Settings
deleteAll() Deletes all setting. Be careful! pheme\settings\components\Settings
get() Get's the value for the given key and section. pheme\settings\components\Settings
getRawConfig() Returns the raw configuration array pheme\settings\components\Settings
init() Initialize the component pheme\settings\components\Settings
set() pheme\settings\components\Settings

Property Details

$cache public property

The cache object or the application component ID of the cache object. Settings will be cached through this cache object, if it is available.

After the Settings object is created, if you want to change this property, you should only assign it with a cache object. Set this property to null if you do not want to cache the settings.

public \yii\caching\Cache|string $cache 'cache'
$cacheKey public property

Cache key

public string $cacheKey 'pheme/settings'
$frontCache public property

The front cache object or the application component ID of the front cache object. Front cache will be cleared through this cache object, if it is available.

After the Settings object is created, if you want to change this property, you should only assign it with a cache object. Set this property to null if you do not want to clear the front cache.

public \yii\caching\Cache|string $frontCache null
$model protected property
$modelClass public property

Settings model. Make sure your settings model calls clearCache in the afterSave callback

public string $modelClass 'pheme\settings\models\Setting'

Method Details

activate() public method

Activates a setting

public bool activate ( $key, $section null )
$key
$section null|string
clearCache() public method

Clears the settings cache on demand.

If you haven't configured cache this does nothing.

public boolean clearCache ( )
return boolean

True if the cache key was deleted and false otherwise

deactivate() public method

Deactivates a setting

public bool deactivate ( $key, $section null )
$key
$section null|string
delete() public method

Deletes a setting

public bool delete ( $key, $section null )
$key
$section null|string
deleteAll() public method

Deletes all setting. Be careful!

public bool deleteAll ( )
get() public method

Get's the value for the given key and section.

You can use dot notation to separate the section from the key: $value = $settings->get('section.key'); and $value = $settings->get('key', 'section'); are equivalent

public mixed get ( $key, $section null, $default null )
$key
$section null
$default null
getRawConfig() public method

Returns the raw configuration array

public array getRawConfig ( )
init() public method

Initialize the component

public void init ( )
throws \yii\base\InvalidConfigException
set() public method

public boolean set ( $key, $value, $section null, $type null )
$key
$value
$section null
$type null