class ConfigManager

Class ConfigManager

Properties

protected ConfigRepository $repo repository instance
protected Validator $validator validator instance
protected array $closures closure list

Methods

__construct(ConfigRepository $repo, Validator $validator)

constructor

add(string $group, array $collection, string $siteKey = 'default')

create new config

mixed
getVal(string $key, mixed $default = null, bool $pure = false, string $siteKey = 'default')

returns config value

mixed
getPureVal(string $key, mixed $default = null, string $siteKey = 'default')

returns config pure value

get(string $group, bool $create = false, string $siteKey = 'default')

returns config object by target name

getOrNew(string $group, string $siteKey = 'default')

if not exists, create new entity object by target name

void
setVal(string $key, mixed $value, bool $toDesc = false, callable $filter = null, string $siteKey = 'default')

set config value

set(string $group, array $collection, bool $toDesc = false, callable $filter = null, string $siteKey = 'default')

multiple set config values

put(string $group, array $collection, bool $toDesc = false, callable $filter = null, string $siteKey = 'default')

config change

modify(ConfigEntity $config)

modify config information

share(ConfigEntity $config, string $item, mixed $value)

shared when closure value

build(ConfigEntity $config)

build config object

void
bindClosure(ConfigEntity $config)

binding registered closure to config

void
convey(ConfigEntity $config, callable $filter = null, array $items = null)

convey to descendants

void
remove(ConfigEntity $config)

remove config

void
removeByName(string $name, string $siteKey = 'default')

remove config by group name

array
children(ConfigEntity $config)

get next level configs

array
parseKey(string $key)

parse a key into group and item

setAncestors(ConfigEntity $config)

ancestors setter

void
validating(ConfigEntity $config)

validation config

array
sort(array $configs, string $flag = 'asc')

sort list

move(ConfigEntity $config, string|null $to = null)

Move entity hierarchy to new parent or root

Details

at line 63
__construct(ConfigRepository $repo, Validator $validator)

constructor

Parameters

ConfigRepository $repo repository instance
Validator $validator validator instance

at line 78
ConfigEntity add(string $group, array $collection, string $siteKey = 'default')

create new config

Parameters

string $group the name of target
array $collection entity value list
string $siteKey site key

Return Value

ConfigEntity

Exceptions

DuplicateException

at line 107
mixed getVal(string $key, mixed $default = null, bool $pure = false, string $siteKey = 'default')

returns config value

Parameters

string $key the name of target including entity name
mixed $default if not exists, be return
bool $pure Do not see the parents
string $siteKey site key

Return Value

mixed

at line 132
mixed getPureVal(string $key, mixed $default = null, string $siteKey = 'default')

returns config pure value

Parameters

string $key the name of target including entity name
mixed $default if not exists, be return
string $siteKey site key

Return Value

mixed

at line 145
ConfigEntity get(string $group, bool $create = false, string $siteKey = 'default')

returns config object by target name

Parameters

string $group the name of target
bool $create if not exists, create new entity object
string $siteKey site key

Return Value

ConfigEntity

at line 168
ConfigEntity getOrNew(string $group, string $siteKey = 'default')

if not exists, create new entity object by target name

Parameters

string $group the name of target
string $siteKey site key

Return Value

ConfigEntity

at line 183
void setVal(string $key, mixed $value, bool $toDesc = false, callable $filter = null, string $siteKey = 'default')

set config value

Parameters

string $key the name of target including entity name
mixed $value the value to be set
bool $toDesc descendants modify if true
callable $filter filter function
string $siteKey site key

Return Value

void

at line 209
ConfigEntity set(string $group, array $collection, bool $toDesc = false, callable $filter = null, string $siteKey = 'default')

multiple set config values

Parameters

string $group the name of target
array $collection items and values to be set
bool $toDesc descendants modify if true
callable $filter filter function
string $siteKey site key

Return Value

ConfigEntity

at line 239
ConfigEntity put(string $group, array $collection, bool $toDesc = false, callable $filter = null, string $siteKey = 'default')

config change

Parameters

string $group the name of target
array $collection items and values to be set
bool $toDesc descendants modify if true
callable $filter filter function
string $siteKey site key

Return Value

ConfigEntity

Exceptions

NotExistsException

at line 266
ConfigEntity modify(ConfigEntity $config)

modify config information

Parameters

ConfigEntity $config config entity instance

Return Value

ConfigEntity

Exceptions

NotExistsException

at line 283
protected ConfigEntity share(ConfigEntity $config, string $item, mixed $value)

shared when closure value

Parameters

ConfigEntity $config config instance
string $item configure key
mixed $value configure value

Return Value

ConfigEntity

at line 306
protected ConfigEntity build(ConfigEntity $config)

build config object

Parameters

ConfigEntity $config config instance

Return Value

ConfigEntity

at line 319
protected void bindClosure(ConfigEntity $config)

binding registered closure to config

Parameters

ConfigEntity $config config instance

Return Value

void

at line 339
protected void convey(ConfigEntity $config, callable $filter = null, array $items = null)

convey to descendants

Parameters

ConfigEntity $config config instance
callable $filter filter function
array $items item key list

Return Value

void

at line 370
void remove(ConfigEntity $config)

remove config

Parameters

ConfigEntity $config config instance

Return Value

void

at line 382
void removeByName(string $name, string $siteKey = 'default')

remove config by group name

Parameters

string $name config group name
string $siteKey site key

Return Value

void

at line 395
array children(ConfigEntity $config)

get next level configs

Parameters

ConfigEntity $config config instance

Return Value

array

at line 418
private array parseKey(string $key)

parse a key into group and item

Parameters

string $key key string

Return Value

array

Exceptions

InvalidArgumentException

at line 437
private ConfigEntity setAncestors(ConfigEntity $config)

ancestors setter

Parameters

ConfigEntity $config config instance

Return Value

ConfigEntity

at line 459
protected void validating(ConfigEntity $config)

validation config

Parameters

ConfigEntity $config config instance

Return Value

void

Exceptions

ValidationException

at line 475
private array sort(array $configs, string $flag = 'asc')

sort list

Parameters

array $configs config instance list
string $flag asc or desc

Return Value

array

at line 504
ConfigEntity move(ConfigEntity $config, string|null $to = null)

Move entity hierarchy to new parent or root

Parameters

ConfigEntity $config config object
string|null $to parent name

Return Value

ConfigEntity

Exceptions

InvalidArgumentException
NoParentException