RdbAdmin Module

Config
in package

Load config files from /config folder from main application or modules in each environment that was set in the /public/index.php file.

This class can load config file, get config value, set config name and value (but not write to the file).

Tags
since
0.1

Table of Contents

Properties

$traceLoadedFiles  : array<string|int, mixed>
$loadedFiles  : array<string|int, mixed>
$moduleSystemName  : string

Methods

__construct()  : mixed
Config class constructor.
__get()  : mixed
Magic get.
get()  : mixed
Get the config value from specified name.
getDefaultLanguage()  : string
Get default language.
getFile()  : string
Get path to config file depend on environment and file that exists.
getWithoutCache()  : mixed
Get the config value from specified name.
load()  : bool
Load the config file into property array.
set()  : mixed
Set config name (key) and value to an existing config file.
setModule()  : mixed
Set the module that this class will be get config from it.
isLoaded()  : bool
Check if config file was loaded. If config file was not loaded, load the config file.

Properties

$traceLoadedFiles

public array<string|int, mixed> $traceLoadedFiles = []

Contain loaded files for use in debug.

$loadedFiles

protected array<string|int, mixed> $loadedFiles = []

Contain loaded files with config name and values. The array format will be as follow.

array(
'system\core' => array(
'config_file_without_extension' => 'its values', // (this is mixed type. maybe string, array, etc.)
'other_file' => array(),
// ...
),
'ModuleSystemName' => array(
// ...
),
)

$moduleSystemName

protected string $moduleSystemName = 'system\\core'

Module system name (folder name) that this class will get config.

Methods

__construct()

Config class constructor.

public __construct() : mixed

You can load this class via framework's Container object named Config. Example: $Config = $Container->get('Config');.

__get()

Magic get.

public __get(string $name) : mixed
Parameters
$name : string
Tags
since
1.1.1

get()

Get the config value from specified name.

public get(string $configKey, string $file[, mixed $default = '' ]) : mixed

This method will get configuration that was temporary cached into property loadedFiles.
The property loadedFiles will be set while it is trying to load the config file via load() method.

This is depend on setModule() method that telling it will get from main app or modules.

Parameters
$configKey : string

The config name. this can set to ALL to get all the config values.

$file : string

Config file name that were loaded. this is without extension.

$default : mixed = ''

Default value if config name is not found.

Return values
mixed

Return config values.

getDefaultLanguage()

Get default language.

public getDefaultLanguage([array<string|int, mixed> $languages = [] ]) : string
Parameters
$languages : array<string|int, mixed> = []

The languages list from config file. Leave this empty to get it from config file again.

Return values
string

Return the language locale string (languageLocaleUrl).

getFile()

Get path to config file depend on environment and file that exists.

public getFile(string $file) : string

This is depend on setModule() method that telling it will get from main app or modules.

Parameters
$file : string

The config file name without extension.

Return values
string

Return full path to config file that different depend on environment.

getWithoutCache()

Get the config value from specified name.

public getWithoutCache(string $configKey, string $file[, mixed $default = '' ]) : mixed

This method will get configuration directly from file in selected module or main app.
Unlike get() method which will try to get config that was temporary cached into property loadedFiles.

This is depend on setModule() method that telling it will get from main app or modules.

Parameters
$configKey : string

The config name. this can set to ALL to get all the config values.

$file : string

Config file name that were loaded. this is without extension.

$default : mixed = ''

Default value if config name is not found.

Tags
since
1.1.1
Return values
mixed

Return config values.

load()

Load the config file into property array.

public load(string $file) : bool

This is depend on setModule() method that telling it will get from main app or modules.

Parameters
$file : string

The config file name without extension. Case sensitive.

Return values
bool

Return true on loaded, false for otherwise.

set()

Set config name (key) and value to an existing config file.

public set(string $file, string $configKey, mixed $configValue) : mixed

This is depend on setModule() method that telling it will set to main app or modules.

Warning! this will not write to the config file.

Parameters
$file : string

Config file name only, no extension. Case sensitive.

$configKey : string

Config name.

$configValue : mixed

Config value.

setModule()

Set the module that this class will be get config from it.

public setModule(string $moduleSystemName) : mixed
Parameters
$moduleSystemName : string

The module system name (folder name). Set to empty string to get it from main app config.

isLoaded()

Check if config file was loaded. If config file was not loaded, load the config file.

private isLoaded(string $file) : bool
Parameters
$file : string

The config file name without extension. case sensitive.

Return values
bool

Return true on loaded, false for otherwise.


        
On this page

Search results