UserPreferencesModel

User Preferences model extension, identical to System\Behaviors\SettingsModel except values are set against the logged in user's preferences via Backend\Models\UserPreference

 class Backend\Behaviors\UserPreferencesModel
extends System\Behaviors\SettingsModel

Add this the model class definition:

public $implement = ['Backend.Behaviors.UserPreferencesModel']; public $settingsCode = 'author.plugin::code'; public $settingsFields = 'fields.yaml';

Extends

Class Description
SettingsModel

Settings model extension

Traits

Trait Description
ConfigMaker

Config Maker Trait Adds configuration based methods to a class

ExtensionTrait

Extension trait

Properties

private static $instances : array

Internal cache of model objects.

inherited public static $extendableStaticCalledClass : string

Inherited from SettingsModel

The calling class when using a static method.

inherited protected $cacheTtl : integer

Inherited from SettingsModel

Settings cache TTL, in seconds.

inherited protected $configPath : string

Inherited from SettingsModel

Specifies a path to the config directory.

inherited protected static $extensionCallbacks : array

Inherited from SettingsModel

Used to extend the constructor of an extension class. Eg:

BehaviorClass::extend(function($obj) { })

inherited protected $extensionHidden : mixed

Inherited from SettingsModel

inherited protected $fieldConfig : mixed

Inherited from SettingsModel

inherited protected $fieldValues : mixed

Inherited from SettingsModel

inherited protected $model : Winter\Storm\Database\Model

Inherited from SettingsModel

Reference to the extended model.

inherited protected $recordCode : mixed

Inherited from SettingsModel

inherited protected $requiredProperties : mixed

Inherited from SettingsModel

Properties that must exist in the model using this behavior.

Methods

public __construct ($model)

Constructor

Parameters
Property Description
$model
mixed
Returns
mixed

public beforeModelSave ()

Before the model is saved, ensure the record code is set and the jsonable field values

Returns
mixed

public getSettingsRecord () : Model

Returns the raw Model record that stores the settings.

Returns
Model

public instance ()

Create an instance of the settings model, intended as a static method

Returns
mixed

public isConfigured () : bool

Checks if the model has been set up previously, intended as a static method

Returns
bool

protected getCacheKey ()

Returns a cache key for this record.

Returns
mixed

protected isKeyAllowed ($key)

Checks if a key is legitimate or should be added to the field value collection

Parameters
Property Description
$key
mixed
Returns
mixed

inherited public afterModelFetch ()

Inherited from SettingsModel

Populate the field values from the database record.

Returns
mixed

inherited public afterModelSave () : void

Inherited from SettingsModel

After the model is saved, clear the cached query entry and restart queue workers so they have the latest settings

Returns
void

inherited public static clearInternalCache () : void

Inherited from SettingsModel

Clears the internal memory cache of model instances.

Returns
void

inherited public static extend (callable $callback)

Inherited from SettingsModel
Parameters
Property Description
$callback
callable
Returns
mixed

inherited public extensionApplyInitCallbacks ()

Inherited from SettingsModel
Returns
mixed

inherited public static extensionExtendCallback (callable $callback) : void

Inherited from SettingsModel

Helper method for ::extend() static method

Parameters
Property Description
$callback
callable
Returns
void

inherited public extensionIsHiddenField ($name)

Inherited from SettingsModel
Parameters
Property Description
$name
mixed
Returns
mixed

inherited public extensionIsHiddenMethod ($name)

Inherited from SettingsModel
Parameters
Property Description
$name
mixed
Returns
mixed

inherited public get ($key, $default = null)

Inherited from SettingsModel

Helper for getSettingsValue, intended as a static method

Parameters
Property Description
$key
mixed
$default
mixed
Returns
mixed

inherited public static getCalledExtensionClass ()

Inherited from SettingsModel
Returns
mixed

inherited public getConfigPath (string $fileName, mixed $configPath = null) : string

Inherited from SettingsModel

Locates a file based on it's definition. If the file starts with the ~ symbol it will be returned in context of the application base path, otherwise it will be returned in context of the config path.

Parameters
Property Description
$fileName
string

File to load.

$configPath
mixed

Explicitly define a config path.

Returns
string

Full path to the config file.

inherited public getFieldConfig ()

Inherited from SettingsModel

Returns the field configuration used by this model.

Returns
mixed

inherited public getSettingsValue ($key, $default = null)

Inherited from SettingsModel

Get a single setting value, or return a default value

Parameters
Property Description
$key
mixed
$default
mixed
Returns
mixed

inherited public guessConfigPath (string $suffix = "") : string

Inherited from SettingsModel

Guess the package path for the called class.

Parameters
Property Description
$suffix
string

An extra path to attach to the end

Returns
string

inherited public guessConfigPathFrom (string $class, string $suffix = "") : string

Inherited from SettingsModel

Guess the package path from a specified class.

Parameters
Property Description
$class
string

Class to guess path from.

$suffix
string

An extra path to attach to the end

Returns
string

inherited public initSettingsData ()

Inherited from SettingsModel

Default values to set for this model, override

Returns
mixed

inherited public makeConfig (array $configFile = [], array $requiredConfig = []) : array | stdClass

Inherited from SettingsModel

Reads the contents of the supplied file and applies it to this object.

Parameters
Property Description
$configFile
array
$requiredConfig
array
Returns
array | stdClass

inherited public makeConfigFromArray (array $configArray = []) : stdClass

Inherited from SettingsModel

Makes a config object from an array, making the first level keys properties of a new object.

Parameters
Property Description
$configArray
array

Config array.

Returns
stdClass

The config object

inherited public mergeConfig (mixed $configA, mixed $configB) : stdClass

Inherited from SettingsModel

Merges two configuration sources, either prepared or not, and returns them as a single configuration object.

Parameters
Property Description
$configA
mixed
$configB
mixed
Returns
stdClass

The config object

inherited public resetDefault ()

Inherited from SettingsModel

Reset the settings to their defaults, this will delete the record model

Returns
mixed

inherited public saveModelInternal () : void

Inherited from SettingsModel

Internal save method for the model

Returns
void

inherited public set ($key, $value = null)

Inherited from SettingsModel

Set a single or array key pair of values, intended as a static method

Parameters
Property Description
$key
mixed
$value
mixed
Returns
mixed

inherited public setSettingsValue ($key, $value)

Inherited from SettingsModel

Set a single setting value, if allowed.

Parameters
Property Description
$key
mixed
$value
mixed
Returns
mixed

inherited protected extensionHideField ($name)

Inherited from SettingsModel
Parameters
Property Description
$name
mixed
Returns
mixed

inherited protected extensionHideMethod ($name)

Inherited from SettingsModel
Parameters
Property Description
$name
mixed
Returns
mixed
Copyright © 2024 Winter CMS