config()
config(string|array|null $key = null, mixed|null $value = null, boolean $merge = true) : mixed
Gets/Sets the config.
Usage
Reading the whole config:
$this->config();
Reading a specific value:
$this->config('key');
Reading a nested value:
$this->config('some.nested.key');
Setting a specific value:
$this->config('key', $value);
Setting a nested value:
$this->config('some.nested.key', $value);
Updating multiple config settings at the same time:
$this->config(['one' => 'value', 'another' => 'value']);
Parameters
string|array|null |
$key |
The key to get/set, or a complete array of configs. |
mixed|null |
$value |
The value to set. |
boolean |
$merge |
Whether to recursively merge or overwrite existing config, defaults to true. |
Throws
- \Cake\Core\Exception\Exception
When trying to set a key that is invalid.
Returns
mixed
— Config value being read, or the object itself on write operations.