minor #14173 Use specialized config methods instead of the generic ifTrue() method (javiereguiluz)

This PR was merged into the 2.3 branch.

Discussion
----------

Use specialized config methods instead of the generic ifTrue() method

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

Commits
-------

dbd02b0 Use specialized config methods instead of the generic ifTrue() method
This commit is contained in:
Fabien Potencier 2015-04-02 15:31:24 +02:00
commit 25f719e90e
2 changed files with 3 additions and 6 deletions

View File

@ -69,10 +69,7 @@ class Configuration implements ConfigurationInterface
->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()
@ -263,7 +260,7 @@ class Configuration implements ConfigurationInterface
->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);
})

View File

@ -58,7 +58,7 @@ class Configuration implements ConfigurationInterface
->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);
})