Documentation

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
copyright

CLOUDREXX CMS - CLOUDREXX AG

author

Reto Kohli reto.kohli@comvation.com

author

Manish Thakur manishthakur@cdnsol.com

version
3.0.0
subpackage

core_setting

todo

Edit PHP DocBlocks!

Table of Contents

Methods

add()  : bool
Add a new record to the settings
alter()  : bool
Alter an existing setting entry
changed()  : bool
Returns the current value of the changed flag.
delete()  : bool
Delete one or more records from the database table
deleteModule()  : bool
Deletes all entries for the current section
errorHandler()  : bool
Should be called whenever there's a problem with the settings
flush()  : void
Flush the stored settings
getArray()  : array<string|int, mixed>
Returns the settings array for the given section and group
getArraySetting()  : array<string|int, mixed>
Returns the settings array for the given section and group
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
update()  : bool
Updates the value for the given name in the settings table
updateAll()  : bool
Stores all settings entries present in the $arrSettings object array variable

Methods

add()

Add a new record to the settings

public add(string $name, string $value[, int $ord = false ][, string $type = 'text' ][, string $values = '' ][, string $group = null ][, bool $flush = true ]) : bool

The class MUST have been initialized by calling init() or getArray() before this method is called. The present $group stored in the class is used as a default. If the current class $group is empty, it MUST be specified in the call.

Parameters
$name : string

The setting name

$value : string

The value

$ord : int = false

The ordinal value for sorting, defaults to 0

$type : string = 'text'

The element type for displaying, defaults to 'text'

$values : string = ''

The values for type 'dropdown', defaults to the empty string

$group : string = null

The optional group

$flush : bool = true

Whether to flush the new setting to the repository.

Return values
bool

True on success, false otherwise

alter()

Alter an existing setting entry

public alter(string $name, string $type[, string $values = '' ][, string $group = '' ][, int $ord = 0 ]) : bool

The class MUST have been initialized by calling init() before this method is called.

Parameters
$name : string

The name of an existing setting entry

$type : string

One of the \Cx\Core\Setting\Controller\Setting::TYPE_* constants

$values : string = ''

The type specific values

$group : string = ''

The group to use. If not set or set to an empty string, the existing group will be left untouched.

$ord : int = 0

The ordinal value for sorting. If not set or set to 0, the existing ordinal value will be left untouched.

Return values
bool

True on success, false otherwise

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

delete()

Delete one or more records from the database table

public delete([string $name = null ][, string $group = null ]) : bool

For maintenance/update purposes only. At least one of the parameter values must be non-empty. It will fail if both are empty. Mind that in this case, no records will be deleted. Does flush() the currently loaded settings on success.

Parameters
$name : string = null

The optional setting name. Defaults to null

$group : string = null

The optional group. Defaults to null

Return values
bool

True on success, false otherwise

deleteModule()

Deletes all entries for the current section

public deleteModule() : bool

This is for testing purposes only. Use with care! The $section determines the module affected.

Return values
bool

True on success, false otherwise

errorHandler()

Should be called whenever there's a problem with the settings

public errorHandler() : bool

Tries to fix or recreate the settings.

Return values
bool

False, always.

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

Returns the settings array for the given section and group

public getArraySetting() : array<string|int, mixed>
Return values
array<string|int, mixed>

getValue()

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
see
init()
see
updateAll()
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

update()

Updates the value for the given name in the settings table

public update(string $name) : bool

The class MUST have been initialized before calling this method using init(), and the new value been set(). Sets $changed to true and returns true if the value has been updated successfully. Note that this method does not work for adding new settings. See add() on how to do this. Also note that the loaded setting is not updated, only the database!

Parameters
$name : string

The settings name

Tags
global

mixed $objDatabase Database connection object

Return values
bool

True on successful update or if unchanged, false on failure

updateAll()

Stores all settings entries present in the $arrSettings object array variable

public updateAll() : bool

Returns boolean true if all records were stored successfully, null if nothing changed (noop), false otherwise. Upon success, also resets the $changed class variable to false. The class MUST have been initialized before calling this method using init(), and the new values been set(). Note that this method does not work for adding new settings. See add() on how to do this.

Return values
bool

True on success, null on noop, false otherwise


        
On this page

Search results