DbConfig
in package
implements
Config
uses
MutableConfigTrait, GetValueInfoTrait, GetValuesTrait
Provides a configuration based on a {@see DbConnection} instance.
Tags
Table of Contents
Interfaces
- Config
- Provides a common interface for configuration providers.
Methods
- __construct() : mixed
- getAllValueInfos() : array<string|int, ConfigValueInfo>
- Lists all value informations from this configuration.
- getArray() : array<string|int, mixed>
- getBoolean() : bool
- getFloat() : float
- getInteger() : int
- getSeparator() : string
- Gets the separator character used for scoping.
- getString() : string
- getValueInfo() : ConfigValueInfo|null
- getValueInfos() : array<string|int, ConfigValueInfo>
- Gets value informations for one or more items.
- getValues() : array<string, mixed>
- Format described in {@see Config::getValues}.
- hasValues() : bool
- Checks if configurations contains given names.
- removeValues() : void
- Removes values with given names from the configuration, if writable.
- reset() : void
- Resets value cache.
- scopeTo() : Config
- Creates a scoped configuration instance that prepends a prefix to all names.
- setArray() : void
- setBoolean() : void
- setFloat() : void
- setInteger() : void
- setString() : void
- setValues() : void
- Sets multiple values at once using an associative array.
- unload() : void
- Unloads specifics items from the local cache.
- validateName() : bool
Methods
__construct()
public
__construct(DbConnection $dbConn, string $tableName[, string $nameField = 'config_name' ][, string $valueField = 'config_value' ][, array<string, mixed> $extraFields = [] ]) : mixed
Parameters
- $dbConn : DbConnection
- $tableName : string
- $nameField : string = 'config_name'
- $valueField : string = 'config_value'
- $extraFields : array<string, mixed> = []
getAllValueInfos()
Lists all value informations from this configuration.
public
getAllValueInfos([int $range = 0 ][, int $offset = 0 ]) : array<string|int, ConfigValueInfo>
Parameters
- $range : int = 0
-
Amount of items to take, 0 for all. Must be a positive integer.
- $offset : int = 0
-
Amount of items to skip. Must be a positive integer. Has no effect if $range is 0.
Return values
array<string|int, ConfigValueInfo> —Configuration value infos.
getArray()
public
getArray(string $name[, array<string|int, mixed> $default = [] ]) : array<string|int, mixed>
Parameters
- $name : string
- $default : array<string|int, mixed> = []
Return values
array<string|int, mixed>getBoolean()
public
getBoolean(string $name[, bool $default = false ]) : bool
Parameters
- $name : string
- $default : bool = false
Return values
boolgetFloat()
public
getFloat(string $name[, float $default = 0 ]) : float
Parameters
- $name : string
- $default : float = 0
Return values
floatgetInteger()
public
getInteger(string $name[, int $default = 0 ]) : int
Parameters
- $name : string
- $default : int = 0
Return values
intgetSeparator()
Gets the separator character used for scoping.
public
getSeparator() : string
Return values
string —Separator character.
getString()
public
getString(string $name[, string $default = '' ]) : string
Parameters
- $name : string
- $default : string = ''
Return values
stringgetValueInfo()
public
getValueInfo(string $name) : ConfigValueInfo|null
Parameters
- $name : string
Return values
ConfigValueInfo|nullgetValueInfos()
Gets value informations for one or more items.
public
getValueInfos(string|array<string|int, mixed> $names) : array<string|int, ConfigValueInfo>
Parameters
- $names : string|array<string|int, mixed>
-
Name or names to retrieve.
Return values
array<string|int, ConfigValueInfo> —Array with value informations.
getValues()
Format described in {@see Config::getValues}.
public
getValues(array<string|int, string|array<string|int, string>> $specs) : array<string, mixed>
Parameters
- $specs : array<string|int, string|array<string|int, string>>
Tags
Return values
array<string, mixed>hasValues()
Checks if configurations contains given names.
public
hasValues(string|array<string|int, mixed> $names) : bool
An empty $names list will always return true.
Parameters
- $names : string|array<string|int, mixed>
-
Name or names to check for.
Return values
bool —Whether all given names are present or not.
removeValues()
Removes values with given names from the configuration, if writable.
public
removeValues(string|array<string|int, mixed> $names) : void
Parameters
- $names : string|array<string|int, mixed>
-
Name or names to remove.
reset()
Resets value cache.
public
reset() : void
scopeTo()
Creates a scoped configuration instance that prepends a prefix to all names.
public
scopeTo(string ...$prefix) : Config
Parameters
- $prefix : string
Return values
Config —A scoped configuration instance.
setArray()
public
setArray(string $name, array<string|int, mixed> $value) : void
Parameters
- $name : string
- $value : array<string|int, mixed>
setBoolean()
public
setBoolean(string $name, bool $value) : void
Parameters
- $name : string
- $value : bool
setFloat()
public
setFloat(string $name, float $value) : void
Parameters
- $name : string
- $value : float
setInteger()
public
setInteger(string $name, int $value) : void
Parameters
- $name : string
- $value : int
setString()
public
setString(string $name, string $value) : void
Parameters
- $name : string
- $value : string
setValues()
Sets multiple values at once using an associative array.
public
setValues(array<string|int, mixed> $values) : void
Parameters
- $values : array<string|int, mixed>
-
Values to save.
unload()
Unloads specifics items from the local cache.
public
unload(string|array<string|int, string> $names) : void
Parameters
- $names : string|array<string|int, string>
-
Names of values to unload.
validateName()
public
static validateName(string $name) : bool
Parameters
- $name : string