Skip to content

Commit

Permalink
Use specialized config methods instead of the generic ifTrue() method
Browse files Browse the repository at this point in the history
  • Loading branch information
javiereguiluz committed Apr 2, 2015
1 parent feb48c2 commit dbd02b0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
Expand Up @@ -69,10 +69,7 @@ public function getConfigTreeBuilder()
->booleanNode('test')->end()
->scalarNode('default_locale')->defaultValue('en')->end()
->arrayNode('trusted_hosts')
->beforeNormalization()
->ifTrue(function ($v) { return is_string($v); })
->then(function ($v) { return array($v); })
->end()
->beforeNormalization()->ifString()->then(function ($v) { return array($v); })->end()
->prototype('scalar')->end()
->end()
->end()
Expand Down Expand Up @@ -263,7 +260,7 @@ private function addTemplatingSection(ArrayNodeDefinition $rootNode)
->addDefaultChildrenIfNoneSet()
->prototype('scalar')->defaultValue('FrameworkBundle:Form')->end()
->validate()
->ifTrue(function ($v) {return !in_array('FrameworkBundle:Form', $v); })
->ifNotInArray(array('FrameworkBundle:Form'))
->then(function ($v) {
return array_merge(array('FrameworkBundle:Form'), $v);
})
Expand Down
Expand Up @@ -58,7 +58,7 @@ private function addFormSection(ArrayNodeDefinition $rootNode)
->prototype('scalar')->defaultValue('form_div_layout.html.twig')->end()
->example(array('MyBundle::form.html.twig'))
->validate()
->ifTrue(function ($v) { return !in_array('form_div_layout.html.twig', $v); })
->ifNotInArray(array('form_div_layout.html.twig'))
->then(function ($v) {
return array_merge(array('form_div_layout.html.twig'), $v);
})
Expand Down

0 comments on commit dbd02b0

Please sign in to comment.