Engine
in package
implements
EngineInterface
Manages settings stored in the database or file system
Before trying to access a modules' settings, DON'T forget to call Setting::init() before calling getValue() for the first time!
Tags
Table of Contents
Interfaces
- EngineInterface
- Manages settings stored in the database or file system
Properties
- $tab_index : int
- Tab counter for the {@see show()} and {@see show_external()}
- $arrSettings : array<string|int, mixed>
- The array of currently loaded settings, like array( 'name' => array( 'section' => section, 'group' => group, 'value' => current value, 'type' => element type (text, dropdown, ... [more to come]), 'values' => predefined values (for dropdown), 'ord' => ordinal number (for sorting), ), ... more ... );
- $changed : bool
- Changed flag
- $group : string
- The group last used to {@see init()} the settings.
- $section : string
- The section last used to {@see init()} the settings.
Methods
- addToArray() : mixed
- Adds element to array
- changed() : bool
- Returns the current value of the changed flag.
- flush() : void
- Flush the stored settings
- getArray() : array<string|int, mixed>
- Returns the settings array for the given section and group
- getArraySetting() : type
- Get array
- getGroup() : group
- Get group
- getSection() : string
- Get section
- getValue() : mixed
- Returns the settings value stored in the object for the name given.
- isDefined() : bool
- Returns the true or false for given the setting name
- set() : bool
- Updates a setting
- tab_index() : int
- Optionally sets and returns the value of the tab index
Properties
$tab_index
Tab counter for the {@see show()} and {@see show_external()}
public
int
$tab_index
= 1
Tags
$arrSettings
The array of currently loaded settings, like array( 'name' => array( 'section' => section, 'group' => group, 'value' => current value, 'type' => element type (text, dropdown, ... [more to come]), 'values' => predefined values (for dropdown), 'ord' => ordinal number (for sorting), ), ... more ... );
protected
array<string|int, mixed>
$arrSettings
= null
Tags
$changed
Changed flag
protected
bool
$changed
= false
This flag is set to true as soon as any change to the settings is detected. It is cleared whenever updateAll() is called.
Tags
$group
The group last used to {@see init()} the settings.
protected
string
$group
= null
Defaults to null (ignored).
Tags
$section
The section last used to {@see init()} the settings.
protected
string
$section
= null
Defaults to null (which will cause an error in most methods).
Tags
Methods
addToArray()
Adds element to array
public
addToArray(string $name, string $item) : mixed
Parameters
- $name : string
- $item : string
changed()
Returns the current value of the changed flag.
public
changed() : bool
If it returns true, you probably want to call updateAll().
Return values
bool —True if values have been changed in memory, false otherwise
flush()
Flush the stored settings
public
flush() : void
Resets the class to its initial state. Does NOT clear the section, however.
getArray()
Returns the settings array for the given section and group
public
getArray(string $section[, string $group = null ]) : array<string|int, mixed>
See init() on how the arguments are used. If the method is called successively using the same $group argument, the current settings are returned without calling init(). Thus, changes made by calling set() will be preserved.
Parameters
- $section : string
-
The section
- $group : string = null
-
The optional group
Return values
array<string|int, mixed> —The settings array on success, false otherwise
getArraySetting()
Get array
public
getArraySetting() : type
Return values
typegetGroup()
Get group
public
getGroup() : group
Return values
groupgetSection()
Get section
public
getSection() : string
Return values
stringgetValue()
Returns the settings value stored in the object for the name given.
public
getValue(string $name) : mixed
If the settings have not been initialized (see init()), or if no setting of that name is present in the current set, null is returned.
Parameters
- $name : string
-
The settings name
Return values
mixed —The settings value, if present, null otherwise
isDefined()
Returns the true or false for given the setting name
public
isDefined(string $name) : bool
If the settings have not been initialized (see init()), or if no setting of that name is present in the current set, false is returned.
Parameters
- $name : string
-
The settings name
Return values
bool —The if setting name is exist returned true, false otherwise
set()
Updates a setting
public
set(string $name, string $value) : bool
If the setting name exists and the new value is not equal to the old one, it is updated, and $changed set to true. Otherwise, nothing happens, and false is returned
Parameters
- $name : string
-
The settings name
- $value : string
-
The settings value
Tags
Return values
bool —True if the value has been changed, false otherwise, null on noop
tab_index()
Optionally sets and returns the value of the tab index
public
tab_index([int $tab_index = null ]) : int
Parameters
- $tab_index : int = null
-
The optional new tab index
Return values
int —The current tab index