ConfigTrait¶
-
trait
atk4\core\
ConfigTrait
¶ - This trait makes it possible for you to read config files and various configurationsuse:1. use Trait in your APP Classuse \atk4\core\ConfigTrait;2. create config-default.php and/or config.php file and add config values like$config[‘key’] = ‘value’;3. call $this->readConfig();before using config.
Source: vendor/atk4/core/src/ConfigTrait.php#15
Properties¶
-
public static property
atk4\core\ConfigTrait::$
_configTrait
¶ - Check this property to see if trait is present in the object.
Source: vendor/atk4/core/src/ConfigTrait.php#22 Type: bool
-
protected static property
atk4\core\ConfigTrait::$
config
¶ - This property stores config values. Use getConfig() method to access its values.
Source: vendor/atk4/core/src/ConfigTrait.php#29 Type: array
Methods¶
-
public
atk4\core\ConfigTrait::
readConfig
( $files=[config.php], $format=php)¶ - Read config file or files and store it in $config property.Supported formats:php - PHP file with $config[‘foo’] = ‘bar’ structurephp-inline - PHP file with return [‘foo’ => ‘bar’] structurejson - JSON file with {‘foo’:’bar’} structureyaml - YAML file with yaml structure
Source: Parameters: - $files (string | array) One or more filenames
- $format (string) Optional format for config files
Throws: Returns: $this
-
public
atk4\core\ConfigTrait::
setConfig
($paths=[], $value=null)¶ - Manually set configuration option.
Source: Parameters: - $paths (string | array) Path to configuration element to set or array of [path=>value]
- $value (mixed) Value to set
Returns: $this
-
public
atk4\core\ConfigTrait::
getConfig
($path, $default_value=null)¶ - Get configuration element.
Source: Parameters: - $path (string) Path to configuration element.
- $default_value (mixed) Default value returned if element don’t exist
Returns: mixed
-
protected
atk4\core\ConfigTrait::
_lookupConfigElement
($path, $create_elements=false)¶ - Internal method to lookup config element by given path.
Source: Parameters: - $path (string) Path to navigate to
- $create_elements (bool) Should we create elements it they don’t exist