refactor: Added general config validations and timezone config
This commit is contained in:
@@ -6,6 +6,7 @@ use Symfony\Component\Config\Definition\ConfigurationInterface;
|
||||
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
|
||||
use Symfony\Component\Config\Definition\Processor;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
use Carbon\CarbonTimeZone;
|
||||
|
||||
class ConfigBuilder implements ConfigurationInterface {
|
||||
private $configs = [];
|
||||
@@ -24,20 +25,32 @@ class ConfigBuilder implements ConfigurationInterface {
|
||||
$treeBuilder = new TreeBuilder();
|
||||
$rootNode = $treeBuilder->root('configs');
|
||||
$ref = $rootNode->children()
|
||||
->arrayNode('logger')
|
||||
->canBeEnabled()
|
||||
->arrayNode('general')
|
||||
->children()
|
||||
->scalarNode('file')->end()
|
||||
->scalarNode('level')
|
||||
->defaultValue('ERROR')
|
||||
->validate()
|
||||
->IfNotInArray(['DEBUG', 'INFO', 'NOTICE', 'WARNING', 'ERROR', 'CRITICAL', 'ALERT', 'EMERGENCY'])
|
||||
->thenInvalid('Invalid log level %s')
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->end();
|
||||
|
||||
->arrayNode('logger')
|
||||
->canBeEnabled()
|
||||
->children()
|
||||
->scalarNode('file')->end()
|
||||
->scalarNode('level')
|
||||
->defaultValue('ERROR')
|
||||
->validate()
|
||||
->IfNotInArray(['DEBUG', 'INFO', 'NOTICE', 'WARNING', 'ERROR', 'CRITICAL', 'ALERT', 'EMERGENCY'])
|
||||
->thenInvalid('Invalid log level %s')
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->scalarNode('timezone')
|
||||
->defaultValue('UTC')
|
||||
->validate()
|
||||
->IfNotInArray(CarbonTimeZone::listIdentifiers())
|
||||
->thenInvalid('Invalid timezone identifier %s')
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->arrayNode('storages')
|
||||
->children();
|
||||
foreach ($this->configs as $config) {
|
||||
$ref = $ref->append($config->get());
|
||||
}
|
||||
|
Reference in New Issue
Block a user