Skip to content

Commit

Permalink
bug #30007 [FrameworkBundle] Support use of hyphen in asset package n…
Browse files Browse the repository at this point in the history
…ame (damaya, XuruDragon)

This PR was merged into the 3.4 branch.

Discussion
----------

[FrameworkBundle] Support use of hyphen in asset package name

This PR is a continuity of #28128

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #29122
| License       | MIT
| Doc PR        | n/a

According to issue symfony/symfony-docs#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.
```yaml
framework:
    assets:
        packages:
            app-client-frontend:
                version: "%env(FRONTEND_VERSION)%"
                version_format: '%%2$s/dist/%%1$s'
                base_urls:
                  - "%env(FRONTEND_URL)%"
```

Commits
-------

5c58b6e Add PackageNameTest to ConfigurationTest also add in the changelog the corresponding entry to this PR
30b6a4f Support use of hyphen in asset package name
  • Loading branch information
fabpot committed Jan 29, 2019
2 parents f797a78 + 5c58b6e commit c95fdbd
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
Expand Up @@ -642,6 +642,7 @@ private function addAssetsSection(ArrayNodeDefinition $rootNode)
->fixXmlConfig('package')
->children()
->arrayNode('packages')
->normalizeKeys(false)
->useAttributeAsKey('name')
->prototype('array')
->fixXmlConfig('base_url')
Expand Down
Expand Up @@ -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
*/
Expand Down

0 comments on commit c95fdbd

Please sign in to comment.