Documentation

rex_config
in package

Class for handling configurations.

The configuration is persisted between requests.

Tags
author

staabm

Table of Contents

Methods

get()  : mixed
Method which returns an associated value for the given namespace and key.
has()  : bool
Returns if the given key is set.
refresh()  : void
Refreshes rex_config by reloading config from db.
remove()  : bool
Removes the setting associated with the given namespace and key.
removeNamespace()  : bool
Removes all settings associated with the given namespace.
save()  : void
persists the config-data and truncates the file-cache.
set()  : bool
Method which saves an arbitary value associated to the given namespace and key.
init()  : void
initilizes the rex_config class.
load()  : void
load the config-data.

Methods

get()

Method which returns an associated value for the given namespace and key.

public static get(string $namespace[, T $key = null ][, mixed $default = null ]) : mixed

If $key is null, an array of all key/value pairs for the given namespace will be returned.

If no value can be found for the given key/namespace combination $default is returned.

Parameters
$namespace : string

The namespace e.g. an addon name

$key : T = null

The associated key

$default : mixed = null

Default return value if no associated-value can be found

Tags
template

T as ?string

throws
InvalidArgumentException
psalm-return

(T is string ? mixed|null : array<string, mixed>)

Return values
mixed

the value for $key or $default if $key cannot be found in the given $namespace

has()

Returns if the given key is set.

public static has(string $namespace[, string|null $key = null ]) : bool
Parameters
$namespace : string

The namespace e.g. an addon name

$key : string|null = null

The associated key

Tags
throws
InvalidArgumentException
Return values
bool

TRUE if the key is set, otherwise FALSE

refresh()

Refreshes rex_config by reloading config from db.

public static refresh() : void

remove()

Removes the setting associated with the given namespace and key.

public static remove(string $namespace, string $key) : bool
Parameters
$namespace : string

The namespace e.g. an addon name

$key : string

The associated key

Tags
throws
InvalidArgumentException
Return values
bool

TRUE if the value was found and removed, otherwise FALSE

removeNamespace()

Removes all settings associated with the given namespace.

public static removeNamespace(string $namespace) : bool
Parameters
$namespace : string

The namespace e.g. an addon name

Tags
throws
InvalidArgumentException
Return values
bool

TRUE if the namespace was found and removed, otherwise FALSE

save()

persists the config-data and truncates the file-cache.

public static save() : void

set()

Method which saves an arbitary value associated to the given namespace and key.

public static set(string $namespace, string|array<string, mixed> $key[, mixed $value = null ]) : bool

If the second parameter is an associative array, all key/value pairs will be saved.

The set-method returns TRUE when an existing value was overridden, otherwise FALSE is returned.

Parameters
$namespace : string

The namespace e.g. an addon name

$key : string|array<string, mixed>

The associated key or an associative array of key/value pairs

$value : mixed = null

The value to save

Tags
throws
InvalidArgumentException
Return values
bool

TRUE when an existing value was overridden, otherwise FALSE

init()

initilizes the rex_config class.

protected static init() : void

load()

load the config-data.

protected static load() : void

        
On this page

Search results