Class JsonConfig

JSON engine allows Configure to load configuration values from files containing JSON strings.

Cake\Core\Configure\Engine\JsonConfig implements Cake\Core\Configure\ConfigEngineInterface uses Cake\Core\Configure\FileConfigTrait

Method Detail

__constructsource public

__construct( string|null $path null )

Constructor for JSON Config file reading.

Parameters

string|null $path optional null
The path to read config files from. Defaults to CONFIG.

dumpsource public

dump( string $key , array $data )

Converts the provided $data into a JSON string that can be used saved into a file and loaded later.

Parameters

string $key
The identifier to write to. If the key has a . it will be treated as a plugin prefix.
array $data
Data to dump.

Returns

boolean
Success

Implementation of

Cake\Core\Configure\ConfigEngineInterface::dump()

readsource public

read( string $key )

Read a config file and return its contents.

Files with . in the name will be treated as values in plugins. Instead of reading from the initialized path, plugin keys will be located using Plugin::path().

Parameters

string $key
The identifier to read from. If the key has a . it will be treated as a plugin prefix.

Returns

array
Parsed configuration values.

Throws

Cake\Core\Exception\Exception
When files don't exist or when files contain '..' (as this could lead to abusive reads) or when there is an error parsing the JSON string.

Implementation of

Cake\Core\Configure\ConfigEngineInterface::read()

Methods used from Cake\Core\Configure\FileConfigTrait

_getFilePathsource protected

_getFilePath( string $key , boolean $checkExists false )

Get file path

Parameters

string $key
The identifier to write to. If the key has a . it will be treated as a plugin prefix.
boolean $checkExists optional false
Whether to check if file exists. Defaults to false.

Returns

string
Full file path

Throws

Cake\Core\Exception\Exception
When files don't exist or when files contain '..' as this could lead to abusive reads.

Properties summary

$_extensionsource

protected string

File extension.

'.json'

Properties used from Cake\Core\Configure\FileConfigTrait

$_pathsource

protected string

The path this engine finds files on.

''

© 2005–2016 The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
http://api.cakephp.org/3.1/class-Cake.Core.Configure.Engine.JsonConfig.html