System\Behaviors\SettingsModel

Overview

SettingsModel extension

Add this the model class definition:

public $implement = [\System\Behaviors\SettingsModel::class];
public $settingsCode = 'author_plugin_code';
public $settingsFields = 'fields.yaml';
Extends
See Also

Public Properties

There are no public properties in the class.

Show inherited public properties

Inherited Public Properties

Protected Properties

protected string $recordCode

protected array $fieldConfig

protected array $fieldValues

protected $requiredProperties

requiredProperties that must exist in the model using this behavior.

protected string $configPath

configPath specifies a path to the config directory.

Show inherited protected properties

Inherited Protected Properties


Public Methods

public __construct()

public __construct($model): void

__construct the settings instance

public afterModelFetch()

public afterModelFetch(): void

afterModelFetch populates the field values from the database record.

public afterModelSave()

public afterModelSave(): void 

afterModelSave clear the cached query entry and restart queue workers so they have the latest settings

public beforeModelSave()

public beforeModelSave(): void

beforeModelSave ensure the record code is set and the jsonable field values

public static clearInternalCache()

public static clearInternalCache(): void 

clearInternalCache of model instances.

public get()

public get($key, $default = null): void

get helper for getSettingsValue, intended as a static method

public getConfigPath()

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

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 getFieldConfig()

public getFieldConfig(): void

getFieldConfig returns the field configuration used by this model.

public getSettingsRecord()

public getSettingsRecord(): Model 

getSettingsRecord returns the raw Model record that stores the settings.

public getSettingsValue()

public getSettingsValue($key, $default = null): void

getSettingsValue gets a single setting value, or return a default value

public guessConfigPath()

public guessConfigPath(string $suffix = ''): string 

guessConfigPath guesses the package path for the called class.

public guessConfigPathFrom()

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

guessConfigPathFrom guesses the package path from a specified class.

public initSettingsData()

public initSettingsData(): void

initSettingsData default values to set for this model, override

public instance()

public instance(): void

instance of the settings model, intended as a static method

public isConfigured()

public isConfigured(): bool 

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

public makeConfig()

public makeConfig(
    mixed $configFile = [],
    array $requiredConfig = []
): object 

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

public makeConfigFromArray()

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

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

public mergeConfig()

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

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

public resetDefault()

public resetDefault(): void

resetDefault this will delete the record model

public saveModelInternal()

public saveModelInternal(): void 

saveModelInternal method for the model

public set()

public set($key, $value = null): void

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

public setSettingsValue()

public setSettingsValue($key, $value): void

setSettingsValue sets a single setting value, if allowed.

Show inherited public methods

Inherited Public Methods

Protected Methods

protected getCacheKey()

protected getCacheKey(): void

getCacheKey returns a cache key for this record.

protected getConfigValueFrom()

protected getConfigValueFrom($configObj, $name = null, $default = null): void

getConfigValueFrom will apply the config getter convention

protected isKeyAllowed()

protected isKeyAllowed($key): void

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

Show inherited protected methods

Inherited Protected Methods