CoreConfig
in package
$this->core->config Class to manage CloudFramework configuration.
Table of Contents
Properties
- $cache : mixed
- $cache_secret_iv : mixed
- $cache_secret_key : mixed
- $data : mixed
- $menu : mixed
- $lang : mixed
- $_configPaths : mixed
- $core : mixed
Methods
- __construct() : mixed
- bulkSet() : mixed
- Set a config vars bases in an Array {"key":"value"}
- convertTags() : mixed|string
- Convert tags inside a string or object
- get() : mixed
- Get a config var value. $var is empty return the array with all values.
- getCache() : mixed
- Get var Cache of the module
- getConfigLoaded() : array<string|int, mixed>
- Return an array of files readed for config.
- getEnvVar() : mixed|null
- Return an environment var from getenv($var) or from a GCP Secret $this->get('core.gcp.secrets.env_vars') in the $this->get('core.gcp.secrets.project_id')
- getLang() : string
- Get the current lang
- inMenuPath() : bool
- Determine if the current URL is part of the menupath
- processConfigData() : mixed
- Process a config array
- pushMenu() : mixed
- Add a menu line
- readCache() : mixed
- Reset Cache of the module
- readConfigJSONFile() : bool
- Try to read a JSON file to process it as a corfig file
- readEnvVarsFromGCPSecrets() : bool
- Allow to read config env_vars taking it from GCP secrets.
- resetCache() : mixed
- Reset Cache of the module
- set() : mixed
- Set a config var
- setLang() : bool
- Assign the language
- updateCache() : mixed
- Update Cache of the module
- getConditionalTagResult() : bool
- Evalue conditional tags on config file
- isAssignationTag() : bool
- Evalue if the tag is a condition
- isConditionalTag() : bool
- Evalue if the tag is a condition
- setAssignationTag() : bool
- Execute an assignation based on the tagcode
Properties
$cache
public
mixed
$cache
= \null
$cache_secret_iv
public
mixed
$cache_secret_iv
= ''
$cache_secret_key
public
mixed
$cache_secret_key
= ''
$data
public
mixed
$data
= []
$menu
public
mixed
$menu
= []
$lang
protected
mixed
$lang
= 'en'
$_configPaths
private
mixed
$_configPaths
= []
$core
private
mixed
$core
Methods
__construct()
public
__construct(Core7 &$core, mixed $path) : mixed
Parameters
- $core : Core7
- $path : mixed
bulkSet()
Set a config vars bases in an Array {"key":"value"}
public
bulkSet( $data) : mixed
Parameters
convertTags()
Convert tags inside a string or object
public
convertTags( $data) : mixed|string
Parameters
Return values
mixed|stringget()
Get a config var value. $var is empty return the array with all values.
public
get([string $var = '' ]) : mixed
Parameters
- $var : string = ''
-
Config variable
getCache()
Get var Cache of the module
public
getCache(string $key[, string $cache_secret_key = '' ][, string $cache_secret_iv = '' ]) : mixed
Parameters
- $key : string
-
key to get from cache
- $cache_secret_key : string = ''
-
optional param to use a specific secret_key. Default value is $this->cache_secret_key
- $cache_secret_iv : string = ''
-
optional param to use a specific secret_iv. Default value is $this->cache_secret_iv
getConfigLoaded()
Return an array of files readed for config.
public
getConfigLoaded() : array<string|int, mixed>
Return values
array<string|int, mixed>getEnvVar()
Return an environment var from getenv($var) or from a GCP Secret $this->get('core.gcp.secrets.env_vars') in the $this->get('core.gcp.secrets.project_id')
public
getEnvVar( $var[, string $gcp_project_id = '' ][, string $gcp_secret_id = '' ]) : mixed|null
Parameters
- $var :
- $gcp_project_id : string = ''
-
optional GCP projectId where the secrets are stored. By default this value is got from $this->get('core.gcp.secrets.project_id')
- $gcp_secret_id : string = ''
-
optional GCP sercretId where env_vars are stored in JSON format. By default this value is got from $this->get('core.gcp.secrets.env_vars')
Return values
mixed|null —if the env var $var exist it returns the contenct and it can be any type
getLang()
Get the current lang
public
getLang() : string
Return values
stringinMenuPath()
Determine if the current URL is part of the menupath
public
inMenuPath() : bool
Return values
boolprocessConfigData()
Process a config array
public
processConfigData( $data) : mixed
Parameters
pushMenu()
Add a menu line
public
pushMenu( $var) : mixed
Parameters
readCache()
Reset Cache of the module
public
readCache([string $cache_secret_key = '' ][, string $cache_secret_iv = '' ]) : mixed
Parameters
- $cache_secret_key : string = ''
-
optional param to use a specific secret_key. Default value is $this->cache_secret_key
- $cache_secret_iv : string = ''
-
optional param to use a specific secret_iv. Default value is $this->cache_secret_iv
readConfigJSONFile()
Try to read a JSON file to process it as a corfig file
public
readConfigJSONFile( $path) : bool
Parameters
Return values
boolreadEnvVarsFromGCPSecrets()
Allow to read config env_vars taking it from GCP secrets.
public
readEnvVarsFromGCPSecrets([mixed $gpc_project_id = '' ][, $gpc_secret_id = '' ][, $reload = false ]) : bool
The secret has to have a JSON structure like { "env_vars:" {"key1":"value1","key2":"value2"}} the result is stored in $this->data['env_vars'].
The result is cached. The config variables needed are:
- core.gcp.secrets.env_vars: name of the secret in GCP
- core.gcp.secrets.cache_path: If the cache is not in memory specify the directory to store the secrets
- core.gcp.secrets.cache_encrypt_key: To encryt the data in cache you can define a config-var key
- core.gcp.secrets.cache_encrypt_iv: To encryt the data in cache you can define a config-var iv
- @param string $cache_secret_key optional secret key. If not empty it will encrypt the data en cache
- @param string $cache_secret_iv optional secret key. If not empty it will encrypt the data en cache *
Parameters
- $gpc_project_id : mixed = ''
- $gpc_secret_id : = ''
-
string secret id in gcp.secrets. if empty it will take $this->get('core.gcp.secrets.env_vars')
- $reload : = false
-
boolean false by default. if true, force to read it from gcp.secrets
Return values
boolresetCache()
Reset Cache of the module
public
resetCache([string $cache_secret_key = '' ][, string $cache_secret_iv = '' ]) : mixed
Parameters
- $cache_secret_key : string = ''
-
optional param to use a specific secret_key. Default value is $this->cache_secret_key
- $cache_secret_iv : string = ''
-
optional param to use a specific secret_iv. Default value is $this->cache_secret_iv
set()
Set a config var
public
set( $var, $data) : mixed
Parameters
setLang()
Assign the language
public
setLang( $lang) : bool
Parameters
Return values
boolupdateCache()
Update Cache of the module
public
updateCache( $var, $data[, string $cache_secret_key = '' ][, string $cache_secret_iv = '' ]) : mixed
Parameters
getConditionalTagResult()
Evalue conditional tags on config file
private
getConditionalTagResult( $tagcode, $tagvalue) : bool
Parameters
Return values
boolisAssignationTag()
Evalue if the tag is a condition
private
isAssignationTag( $tag) : bool
Parameters
Return values
boolisConditionalTag()
Evalue if the tag is a condition
private
isConditionalTag( $tag) : bool
Parameters
Return values
boolsetAssignationTag()
Execute an assignation based on the tagcode
private
setAssignationTag( $tagcode, $tagvalue, mixed $vars) : bool