From 8c1672743d7069c1b4eb57252a3e3f5385c2935c Mon Sep 17 00:00:00 2001 From: Lars Strojny Date: Tue, 3 Apr 2018 14:46:42 +0200 Subject: [PATCH] =?UTF-8?q?Don=E2=80=99t=20normalize=20global=20values?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DependencyInjection/Configuration.php | 1 + .../DependencyInjection/ConfigurationTest.php | 24 +++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Configuration.php index 53e33d647d..0a8d34643b 100644 --- a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Configuration.php +++ b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Configuration.php @@ -76,6 +76,7 @@ class Configuration implements ConfigurationInterface ->useAttributeAsKey('key') ->example(array('foo' => '"@bar"', 'pi' => 3.14)) ->prototype('array') + ->normalizeKeys(false) ->beforeNormalization() ->ifTrue(function ($v) { return is_string($v) && 0 === strpos($v, '@'); }) ->then(function ($v) { diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/ConfigurationTest.php b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/ConfigurationTest.php index bd8482cd9e..3091b0aa85 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/ConfigurationTest.php +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/ConfigurationTest.php @@ -41,4 +41,28 @@ class ConfigurationTest extends TestCase $this->assertFalse($config['strict_variables']); } + + public function testGlobalsAreNotNormalized() + { + $input = array( + 'globals' => array('some-global' => true), + ); + + $processor = new Processor(); + $config = $processor->processConfiguration(new Configuration(), array($input)); + + $this->assertSame(array('some-global' => array('value' => true)), $config['globals']); + } + + public function testArrayKeysInGlobalsAreNotNormalized() + { + $input = array( + 'globals' => array('global' => array('some-key' => 'some-value')), + ); + + $processor = new Processor(); + $config = $processor->processConfiguration(new Configuration(), array($input)); + + $this->assertSame(array('global' => array('value' => array('some-key' => 'some-value'))), $config['globals']); + } }