Skip to content

Commit

Permalink
scrutinizer code quality fix #5
Browse files Browse the repository at this point in the history
  • Loading branch information
sadikoff committed Dec 22, 2017
1 parent 1055ce8 commit eb5d206
Showing 1 changed file with 15 additions and 26 deletions.
41 changes: 15 additions & 26 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,33 +20,22 @@ class Configuration implements ConfigurationInterface
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('koff_i18n_form');
$root = $treeBuilder->root('koff_i18n_form')->children();

$rootNode
->children()
->arrayNode('locales')
->defaultValue(['en'])
->beforeNormalization()
->ifString()->then(function ($v) {return preg_split('/\s*[,|]\s*/', $v); })
->end()
->requiresAtLeastOneElement()
->prototype('scalar')->end()
->end()
->arrayNode('required_locales')
->beforeNormalization()
->ifString()->then(function ($v) {return preg_split('/\s*[,|]\s*/', $v); })
->end()
->prototype('scalar')->end()
->end()
->arrayNode('excluded_fields')
->defaultValue(['id', 'locale', 'translatable'])
->beforeNormalization()
->ifString()->then(function ($v) {return preg_split('/\s*[,|]\s*/', $v); })
->end()
->prototype('scalar')->end()
->end()
->end()
;
$locales = $root->arrayNode('locales');
$locales->defaultValue(['en']);
$locales->beforeNormalization()->ifString()->then(function ($v) {return preg_split('/\s*[,|]\s*/', $v); });
$locales->requiresAtLeastOneElement();
$locales->prototype('scalar');

$required = $root->arrayNode('required_locales');
$required->beforeNormalization()->ifString()->then(function ($v) {return preg_split('/\s*[,|]\s*/', $v); });
$required->prototype('scalar');

$excluded = $root->arrayNode('excluded_fields');
$excluded->defaultValue(['id', 'locale', 'translatable']);
$excluded->beforeNormalization()->ifString()->then(function ($v) {return preg_split('/\s*[,|]\s*/', $v); });
$excluded->prototype('scalar');

return $treeBuilder;
}
Expand Down

0 comments on commit eb5d206

Please sign in to comment.