From 30b6a4f7bfc1893a29c7f3e101df2cd6b8b87829 Mon Sep 17 00:00:00 2001 From: damaya Date: Fri, 3 Aug 2018 17:44:03 -0500 Subject: [PATCH 1/2] Support use of hyphen in asset package name | Q | A | ------------- | --- | Branch? | master | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes (Manual tests only) | Fixed tickets | #28122 | License | MIT | Doc PR | n/a According to issue https://github.com/symfony/symfony-docs/pull/10442, we tested in a demo bundle, for example in src/AppBundle/Resources/config/config.yml a package using hyphens: app-client-frontend, and withouth the patch it fails because the package is not recognized. With the patch, it works as expected. ``` framework: assets: packages: app-client-frontend: version: "%env(FRONTEND_VERSION)%" version_format: '%%2$s/dist/%%1$s' base_urls: - "%env(FRONTEND_URL)%" ``` --- .../Bundle/FrameworkBundle/DependencyInjection/Configuration.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php index 6a6441a39c86..f49c5f11e0ee 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php @@ -642,6 +642,7 @@ private function addAssetsSection(ArrayNodeDefinition $rootNode) ->fixXmlConfig('package') ->children() ->arrayNode('packages') + ->normalizeKeys(false) ->useAttributeAsKey('name') ->prototype('array') ->fixXmlConfig('base_url') From 5c58b6e8759c595dc53899d55b1e6c86547d2582 Mon Sep 17 00:00:00 2001 From: Anthony MARTIN Date: Mon, 28 Jan 2019 14:09:39 +0100 Subject: [PATCH 2/2] Add PackageNameTest to ConfigurationTest also add in the changelog the corresponding entry to this PR --- .../DependencyInjection/ConfigurationTest.php | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php index 1be4015713dc..91764a642e8d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php @@ -211,6 +211,35 @@ public function testAssetsCanBeEnabled() $this->assertEquals($defaultConfig, $config['assets']); } + /** + * @dataProvider provideValidAssetsPackageNameConfigurationTests + */ + public function testValidAssetsPackageNameConfiguration($packageName) + { + $processor = new Processor(); + $configuration = new Configuration(true); + $config = $processor->processConfiguration($configuration, [ + [ + 'assets' => [ + 'packages' => [ + $packageName => [], + ], + ], + ], + ]); + + $this->assertArrayHasKey($packageName, $config['assets']['packages']); + } + + public function provideValidAssetsPackageNameConfigurationTests() + { + return [ + ['foobar'], + ['foo-bar'], + ['foo_bar'], + ]; + } + /** * @dataProvider provideInvalidAssetConfigurationTests */