Documentation

UserPreferencesModel extends SettingsModel
in package

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

Add this the model class definition:

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

Table of Contents

$extendableStaticCalledClass  : string
$configPath  : string
$extensionCallbacks  : array<string|int, mixed>
$extensionHidden  : mixed
$fieldConfig  : mixed
$fieldValues  : mixed
$model  : Model
$recordCode  : mixed
$requiredProperties  : array<string|int, mixed>
$instances  : array<string|int, mixed>
__construct()  : mixed
Constructor
afterModelFetch()  : mixed
Populate the field values from the database record.
afterModelSave()  : void
After the model is saved, clear the cached query entry and restart queue workers so they have the latest settings
beforeModelSave()  : mixed
Before the model is saved, ensure the record code is set and the jsonable field values
clearInternalCache()  : void
Clears the internal memory cache of model instances.
extend()  : mixed
extensionApplyInitCallbacks()  : mixed
extensionExtendCallback()  : void
Helper method for `::extend()` static method
extensionIsHiddenField()  : mixed
extensionIsHiddenMethod()  : mixed
get()  : mixed
Helper for getSettingsValue, intended as a static method
getCalledExtensionClass()  : mixed
getConfigPath()  : string
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.
getFieldConfig()  : mixed
Returns the field configuration used by this model.
getSettingsRecord()  : Model
Returns the raw Model record that stores the settings.
getSettingsValue()  : mixed
Get a single setting value, or return a default value
guessConfigPath()  : string
Guess the package path for the called class.
guessConfigPathFrom()  : string
Guess the package path from a specified class.
initSettingsData()  : mixed
Default values to set for this model, override
instance()  : mixed
Create an instance of the settings model, intended as a static method
isConfigured()  : bool
Checks if the model has been set up previously, intended as a static method
makeConfig()  : array<string|int, mixed>|stdClass
Reads the contents of the supplied file and applies it to this object.
makeConfigFromArray()  : stdClass
Makes a config object from an array, making the first level keys properties of a new object.
mergeConfig()  : stdClass
Merges two configuration sources, either prepared or not, and returns them as a single configuration object.
resetDefault()  : mixed
Reset the settings to their defaults, this will delete the record model
saveModelInternal()  : void
Internal save method for the model
set()  : mixed
Set a single or array key pair of values, intended as a static method
setSettingsValue()  : mixed
Set a single setting value, if allowed.
extensionHideField()  : mixed
extensionHideMethod()  : mixed
getCacheKey()  : mixed
Returns a cache key for this record.
isKeyAllowed()  : mixed
Checks if a key is legitimate or should be added to the field value collection

Properties

$extendableStaticCalledClass

public static string $extendableStaticCalledClass = null

The calling class when using a static method.

$configPath

protected string $configPath

Specifies a path to the config directory.

$extensionCallbacks

protected static array<string|int, mixed> $extensionCallbacks = []

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

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

$extensionHidden

protected mixed $extensionHidden = ['fields' => [], 'methods' => ['extensionIsHiddenField', 'extensionIsHiddenMethod']]

$requiredProperties

protected array<string|int, mixed> $requiredProperties = []

Properties that must exist in the model using this behavior.

$instances

private static array<string|int, mixed> $instances = []

Internal cache of model objects.

Methods

__construct()

Constructor

public __construct(mixed $model) : mixed
Parameters
$model : mixed

The extended model.

Return values
mixed

afterModelFetch()

Populate the field values from the database record.

public afterModelFetch() : mixed
Return values
mixed

afterModelSave()

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

public afterModelSave() : void
Return values
void

beforeModelSave()

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

public beforeModelSave() : mixed
Return values
mixed

clearInternalCache()

Clears the internal memory cache of model instances.

public static clearInternalCache() : void
Return values
void

extend()

public static extend(callable $callback) : mixed
Parameters
$callback : callable
Return values
mixed

extensionApplyInitCallbacks()

public extensionApplyInitCallbacks() : mixed
Return values
mixed

extensionExtendCallback()

Helper method for `::extend()` static method

public static extensionExtendCallback(callable $callback) : void
Parameters
$callback : callable
Return values
void

extensionIsHiddenField()

public extensionIsHiddenField(mixed $name) : mixed
Parameters
$name : mixed
Return values
mixed

extensionIsHiddenMethod()

public extensionIsHiddenMethod(mixed $name) : mixed
Parameters
$name : mixed
Return values
mixed

get()

Helper for getSettingsValue, intended as a static method

public get(mixed $key[, mixed $default = null ]) : mixed
Parameters
$key : mixed
$default : mixed = null
Return values
mixed

getCalledExtensionClass()

public static getCalledExtensionClass() : mixed
Return values
mixed

getConfigPath()

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.

public getConfigPath(string $fileName[, mixed $configPath = null ]) : string
Parameters
$fileName : string

File to load.

$configPath : mixed = null

Explicitly define a config path.

Return values
string

Full path to the config file.

getFieldConfig()

Returns the field configuration used by this model.

public getFieldConfig() : mixed
Return values
mixed

getSettingsRecord()

Returns the raw Model record that stores the settings.

public getSettingsRecord() : Model
Return values
Model

getSettingsValue()

Get a single setting value, or return a default value

public getSettingsValue(mixed $key[, mixed $default = null ]) : mixed
Parameters
$key : mixed
$default : mixed = null
Return values
mixed

guessConfigPath()

Guess the package path for the called class.

public guessConfigPath([string $suffix = '' ]) : string
Parameters
$suffix : string = ''

An extra path to attach to the end

Return values
string

guessConfigPathFrom()

Guess the package path from a specified class.

public guessConfigPathFrom(string $class[, string $suffix = '' ]) : string
Parameters
$class : string

Class to guess path from.

$suffix : string = ''

An extra path to attach to the end

Return values
string

initSettingsData()

Default values to set for this model, override

public initSettingsData() : mixed
Return values
mixed

instance()

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

public instance() : mixed
Return values
mixed

isConfigured()

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

public isConfigured() : bool
Return values
bool

makeConfig()

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

public makeConfig([array<string|int, mixed> $configFile = [] ][, array<string|int, mixed> $requiredConfig = [] ]) : array<string|int, mixed>|stdClass
Parameters
$configFile : array<string|int, mixed> = []
$requiredConfig : array<string|int, mixed> = []
Return values
array<string|int, mixed>|stdClass

makeConfigFromArray()

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

public makeConfigFromArray([array<string|int, mixed> $configArray = [] ]) : stdClass
Parameters
$configArray : array<string|int, mixed> = []

Config array.

Return values
stdClass

The config object

mergeConfig()

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

public mergeConfig(mixed $configA, mixed $configB) : stdClass
Parameters
$configA : mixed
$configB : mixed
Return values
stdClass

The config object

resetDefault()

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

public resetDefault() : mixed
Return values
mixed

saveModelInternal()

Internal save method for the model

public saveModelInternal() : void
Return values
void

set()

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

public set(mixed $key[, mixed $value = null ]) : mixed
Parameters
$key : mixed
$value : mixed = null
Return values
mixed

setSettingsValue()

Set a single setting value, if allowed.

public setSettingsValue(mixed $key, mixed $value) : mixed
Parameters
$key : mixed
$value : mixed
Return values
mixed

extensionHideField()

protected extensionHideField(mixed $name) : mixed
Parameters
$name : mixed
Return values
mixed

extensionHideMethod()

protected extensionHideMethod(mixed $name) : mixed
Parameters
$name : mixed
Return values
mixed

getCacheKey()

Returns a cache key for this record.

protected getCacheKey() : mixed
Return values
mixed

isKeyAllowed()

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

protected isKeyAllowed(mixed $key) : mixed
Parameters
$key : mixed
Return values
mixed

Search results