class SettingsModel extends ModelAction

Settings model extension Based on October/ModelBehaviour Usage: In the model class definition: public $implement = ['System\Actions\SettingsModel']; public $settingsCode = 'owner_extension_settings'; public $settingsFieldsConfig = 'settings_model';

Traits

Extension trait

Properties

string $configPath from  ConfigMaker
protected $configFileExtension from  ConfigMaker
static protected array $extensionCallbacks from  ExtensionTrait
static string $extendableStaticCalledClass from  ExtensionTrait
protected $extensionHidden from  ExtensionTrait
protected Model $model from  ModelAction
protected $requiredProperties
protected $recordCode
protected $fieldConfig
protected $fieldValues
static private array $instances

Methods

array
loadConfig(array $configFile = [], array $requiredConfig = [], null $index = null)

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

array
makeConfig(string|array $configFile, array $requiredConfig = [])

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

array
mergeConfig($configLeft, $configRight)

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

string
getConfigPath(string $fileName, mixed $configPath = null)

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.

string
guessConfigPath(string $suffix = '')

Guess the package path for the called class.

string
guessConfigPathFrom(string $class, string $suffix = '')

Guess the package path from a specified class.

static void
extensionExtendCallback(callable $callback)

Helper method for ::extend() static method

extensionHideField($name)

No description

extensionHideMethod($name)

No description

extensionIsHiddenField($name)

No description

extensionIsHiddenMethod($name)

No description

static 
getCalledExtensionClass()

No description

__construct(null $model)

Constructor

instance()

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

resetDefault()

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

bool
isConfigured()

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

getSettingsRecord()

Returns the raw Model record that stores the settings.

set($key, $value = null)

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

get($key, $default = null)

Helper for getSettingsValue, intended as a static method

getSettingsValue($key, $default = null)

Get a single setting value, or return a default value

setSettingsValue($key, $value)

Set a single setting value, if allowed.

initSettingsData()

Default values to set for this model, override

afterModelFetch()

Populate the field values from the database record.

void
saveModelInternal()

Internal save method for the model

beforeModelSave()

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

void
afterModelSave()

After the model is saved, clear the cached query entry.

isKeyAllowed($key)

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

getFieldConfig()

Returns the field configuration used by this model.

getCacheKey()

Returns a cache key for this record.

static void
clearInternalCache()

Clears the internal memory cache of model instances.

Details

in ConfigMaker at line 27
array loadConfig(array $configFile = [], array $requiredConfig = [], null $index = null)

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

Parameters

array $configFile
array $requiredConfig
null $index

Return Value

array

in ConfigMaker at line 46
array makeConfig(string|array $configFile, array $requiredConfig = [])

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

Parameters

string|array $configFile
array $requiredConfig

Return Value

array

Exceptions

SystemException

in ConfigMaker at line 97
array mergeConfig($configLeft, $configRight)

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

Parameters

$configLeft
$configRight

Return Value

array

The config array

in ConfigMaker at line 116
string getConfigPath(string $fileName, mixed $configPath = null)

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

string $fileName

File to load.

mixed $configPath

Explicitly define a config path.

Return Value

string

Full path to the config file.

in ConfigMaker at line 154
string guessConfigPath(string $suffix = '')

Guess the package path for the called class.

Parameters

string $suffix

An extra path to attach to the end

Return Value

string

in ConfigMaker at line 169
string guessConfigPathFrom(string $class, string $suffix = '')

Guess the package path from a specified class.

Parameters

string $class

Class to guess path from.

string $suffix

An extra path to attach to the end

Return Value

string

in ExtensionTrait at line 32
extensionApplyInitCallbacks()

No description

in ExtensionTrait at line 51
static void extensionExtendCallback(callable $callback)

Helper method for ::extend() static method

Parameters

callable $callback

Return Value

void

in ExtensionTrait at line 64
protected extensionHideField($name)

No description

Parameters

$name

in ExtensionTrait at line 69
protected extensionHideMethod($name)

No description

Parameters

$name

in ExtensionTrait at line 74
extensionIsHiddenField($name)

No description

Parameters

$name

in ExtensionTrait at line 79
extensionIsHiddenMethod($name)

No description

Parameters

$name

in ExtensionTrait at line 84
static getCalledExtensionClass()

No description

at line 37
__construct(null $model)

Constructor

Parameters

null $model

at line 66
instance()

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

at line 83
resetDefault()

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

at line 95
bool isConfigured()

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

Return Value

bool

at line 104
Model getSettingsRecord()

Returns the raw Model record that stores the settings.

Return Value

Model

at line 114
set($key, $value = null)

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

Parameters

$key
$value

at line 126
get($key, $default = null)

Helper for getSettingsValue, intended as a static method

Parameters

$key
$default

at line 134
getSettingsValue($key, $default = null)

Get a single setting value, or return a default value

Parameters

$key
$default

at line 149
setSettingsValue($key, $value)

Set a single setting value, if allowed.

Parameters

$key
$value

at line 161
initSettingsData()

Default values to set for this model, override

at line 168
afterModelFetch()

Populate the field values from the database record.

at line 178
void saveModelInternal()

Internal save method for the model

Return Value

void

at line 188
beforeModelSave()

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

at line 200
void afterModelSave()

After the model is saved, clear the cached query entry.

Return Value

void

at line 208
protected isKeyAllowed($key)

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

Parameters

$key

at line 226
getFieldConfig()

Returns the field configuration used by this model.

at line 238
protected getCacheKey()

Returns a cache key for this record.

at line 247
static void clearInternalCache()

Clears the internal memory cache of model instances.

Return Value

void