A Config Lexicon is a list of config keys used by current app. Each entry also define the expected type for the config value, its lazyness/sensitivity.
The loading is done by registering a IConfigLexicon.
Application.php
public function register(IRegistrationContext $context): void {
$context->registerConfigLexicon(ConfigLexicon::class);
}
ConfigLexicon.php
class Lexicon implements IConfigLexicon {
public function isStrict(): bool {
return false;
}
public function getAppConfigs(): array {
return [
new ConfigLexiconEntry('key1', IConfigLexiconEntry::TYPE_STRING, defintion: 'this is a test config key', lazy: true),
new ConfigLexiconEntry('key2', IConfigLexiconEntry::TYPE_STRING, sensitive: true),
new ConfigLexiconEntry('key3', IConfigLexiconEntry::TYPE_INT, 42),
new ConfigLexiconEntry('key4', IConfigLexiconEntry::TYPE_STRING),
];
}
public function getUserPreferences(): array {
return [];
}
}
Note: A description of the config key can be added as 3rd parameter of the ConfigLexiconEntry. This information is not stored when running from a web process.
store and retrieve config value
Once this is done:
any code trying to wrongly type config values will get an exception
$ ./occ config:app:set myapp key1 --value 1 --type integer
In AppConfig.php line 1544:
The key is typed incorrectly in relation to the app config lexicon
set/get on config values set as lazy will work even if not specified in the process
A
Config Lexicon
is a list of config keys used by current app. Each entry also define the expected type for the config value, its lazyness/sensitivity. The loading is done by registering aIConfigLexicon
.Application.php
ConfigLexicon.php
Note: A description of the config key can be added as 3rd parameter of the
ConfigLexiconEntry
. This information is not stored when running from a web process.store and retrieve config value
Once this is done:
any code trying to wrongly type config values will get an exception
set/get on config values set as lazy will work even if not specified in the process
default value can be overwritten
will returns
42
If configured as
strict
, setting an unlisted config values returns an exceptionAlso, setting a config key as deprecated will generate a level 1 log entry when the config key is used