-
Notifications
You must be signed in to change notification settings - Fork 0
Configuration
In concrete 5.7 the configuration has been completely overhauled. Gone are the days where constants are slung about, in the name of configuration. Instead, we now have a new way for setting, and retrieving configuration options, which are fully overridable, and are hierarchical in design.
The new configuration “key” consists of 3 parts:
- Namespace - This will be blank for core configurations, or the package handle for any package configurations.
- Group - The group that the config item belongs to.
- Item - The index of the configuration key The above parts can be used to look up the value of the configuration.
The new configuration allows for configuration settings to be nested in groups.
https://github.com/concrete5/concrete5-5.7.0/blob/develop/tests/tests/Core/Config/FileLoaderTest.php
// This should be helpful in understanding how environments work. Defining them is done in /application/bootstrap/start.php
Load group $group namespace null:
/concrete/config/{$group}.php
/application/config/generated_overrides/{$group}.php
/application/config/{$group}.php
/application/config/{$environment}/{$group}.php
Load group $group namespace $namespace
/application/config/generated_overrides/{$namespace}/{$group}.php
/application/config/{$namespace}/{$group}.php
/application/config/{$environment}/{$namespace}/{$group}.php
// Read / Write methods
\Config::get(‘my.local.test’, $default=null)
\Config::has(‘my.local.test’)
\Config::set(‘my.local.test’, ‘abc’)
\Config::save(‘my.local.test’, ‘abc’)
The group is important because it is the "index" on which the configuration gets zipped up.
\Config::get(‘group.item.item.item’) will do something like this:
if ($this->hasGroupCached('group')) {
$group = $this->getCachedGroup('group');
} else {
$group = $this->getConfigLoader()->loadGroup('group');
$this->cacheGroup('group', $group);
}
return array_get($group, 'item.item.item');Key spec: (see these examples)
/^(?:(?P<Namespace>.+?)::)?(?P<Group>[^.]+).(?P<Item>.+)$/namespace::group.itemgroup.item
namespace::groupgroup
namespace
cache.levels.expensive.drivers
Namespace = NULL
Group = cache
Item = levels.expensive.drivers
At this point, a saved config VALUE needs to have two things: a group and an item. It can optionally be namespaced.
if I do \Config::save(‘group’, ‘value’); it should either case to an array and save as group.1 => ‘value’ or throw an exception, since the value doesn’t have the two required things.