From dbd02b087175c7817a39d047c6f6e237b8adeca5 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Thu, 2 Apr 2015 13:05:24 +0200 Subject: [PATCH] Use specialized config methods instead of the generic ifTrue() method --- .../FrameworkBundle/DependencyInjection/Configuration.php | 7 ++----- .../TwigBundle/DependencyInjection/Configuration.php | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php index 2de60489a8b6..08bcc1c19db7 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php @@ -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() @@ -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); }) diff --git a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Configuration.php index a20ca8c1a86d..8cc114ab2922 100644 --- a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Configuration.php +++ b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Configuration.php @@ -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); })