8000 [Asset] ability to set assets_version_strategy as service by ewgRa · Pull Request #16522 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Asset] ability to set assets_version_strategy as service #16522

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

10000
Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10000
Prev Previous commit
Next Next commit
Merge remote-tracking branch 'upstream/2.8' into assets_version_strategy
Conflicts:
	src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php
	src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
	src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/assets.php
	src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/legacy_templating_assets.php
	src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/assets.xml
	src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/legacy_templating_assets.xml
	src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/assets.yml
	src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/legacy_templating_assets.yml
	src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php
  • Loading branch information
ewgRa committed Jan 24, 2016
commit d52142fea502d4a83d5802dadf23f9ea752ee274
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public function getConfigTreeBuilder()

$v['assets']['packages'][$name] = array(
'version_strategy' => $config['version_strategy'],
'version' => (string) $config['version'],
'version' => null === $config['version'] ? null : (string) $config['version'],
'version_format' => $config['version_format'],
'base_path' => '',
'base_urls' => array_values(array_unique(array_merge($config['base_urls']['http'], $config['base_urls']['ssl']))),
Expand Down Expand Up @@ -563,7 +563,13 @@ private function addTemplatingSection(ArrayNodeDefinition $rootNode)
->fixXmlConfig('base_url')
->children()
->scalarNode('version_strategy')->defaultNull()->end()
->scalarNode('version')->defaultNull()->end()
->scalarNode('version')
->defaultNull()
->beforeNormalization()
->ifTrue(function ($v) { return '' === $v; })
->then(function ($v) { return; })
->end()
->end()
->scalarNode('version_format')->defaultValue('%%s?%%s')->end()
->arrayNode('base_urls')
->performNoDeepMerging()
Expand Down Expand Up @@ -624,7 +630,12 @@ private function addAssetsSection(ArrayNodeDefinition $rootNode)
->fixXmlConfig('base_url')
->children()
->scalarNode('version_strategy')->defaultNull()->end()
->scalarNode('version')->defaultNull()->end()
->scalarNode('version')
->beforeNormalization()
->ifTrue(function ($v) { return '' === $v; })
->then(function ($v) { return; })
->end()
->end()
->scalarNode('version_format')->defaultNull()->end()
->scalarNode('base_path')->defaultValue('')->end()
->arrayNode('base_urls')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ private function registerAssetsConfiguration(array $config, ContainerBuilder $co
foreach ($config['packages'] as $name => $package) {
if (null !== $package['version_strategy']) {
$version = new Reference($package['version_strategy']);
} else if (null === $package['version']) {
} else if (!array_key_exists('version', $package)) {
$version = $defaultVersion;
} else {
$format = $package['version_format'] ?: $config['version_format'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
'bar' => array(
'base_urls' => array('https://bar2.example.com'),
),
'bar_null_version' => array(
'version' => null,
'base_urls' => array('https://bar3.example.com'),
),
'bar_version_strategy' => array(
'base_urls' => array('https://bar2.example.com'),
'version_strategy' => 'assets.custom_version_strategy',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
'bar' => array(
'base_urls' => array('https://bar2.example.com'),
),
'bar_null_version' => array(
'version' => null,
'base_urls' => array('https://bar3.example.com'),
'bar_version_strategy' => array(
'base_urls' => array('https://bar2.example.com'),
'version_strategy' => 'assets.custom_version_strategy',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
<framework:package name="bar">
<framework:base-url>https://bar2.example.com</framework:base-url>
</framework:package>
<framework:package name="bar_null_version" version="">
<framework:base-url>https://bar3.example.com</framework:base-url>
</framework:package>
<framework:package name="bar_version_strategy" version-strategy="assets.custom_version_strategy">
<framework:base-url>https://bar_version_strategy.example.com</framework:base-url>
</framework:package>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
<framework:package name="bar">
<framework:base-url>https://bar2.example.com</framework:base-url>
</framework:package>
<framework:package name="bar_null_version" version="">
<framework:base-url>https://bar3.example.com</framework:base-url>
</framework:package>
<framework:package name="bar_version_strategy" version-strategy="assets.custom_version_strategy">
<framework:base-url>https://bar_version_strategy.example.com</framework:base-url>
</framework:package>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ framework:
version_format: %%s-%%s
bar:
base_urls: ["https://bar2.example.com"]
bar_null_version:
version: null
base_urls: "https://bar3.example.com"
bar_version_strategy:
base_urls: ["https://bar_version_strategy.example.com"]
version_strategy: assets.custom_version_strategy
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ framework:
version_format: %%s-%%s
bar:
base_urls: "https://bar2.example.com"
bar_null_version:
version: null
base_urls: "https://bar3.example.com"
bar_version_strategy:
base_urls: ["https://bar_version_strategy.example.com"]
version_strategy: assets.custom_version_strategy
720E
Original file line number Diff line number Diff line change
Expand Up @@ -215,34 +215,11 @@ public function testLegacyTemplatingAssets()
$this->checkAssetsPackages($this->createContainerFromFile('legacy_templating_assets'), true);
}

/**
* @group legacy
*/
public function testLegacyAssetsDefaultVersionStrategyAsService()
{
$container = $this->createContainerFromFile('legacy_templating_assets_version_strategy_as_service');
$packages = $container->getDefinition('assets.packages');

// default package
$defaultPackage = $container->getDefinition($packages->getArgument(0));
$this->assertEquals('assets.custom_version_strategy', (string) $defaultPackage->getArgument(1));
}

public function testAssets()
{
$this->checkAssetsPackages($this->createContainerFromFile('assets'));
}

public function testAssetsDefaultVersionStrategyAsService()
{
$container = $this->createContainerFromFile('assets_version_strategy_as_service');
$packages = $container->getDefinition('assets.packages');

// default package
$defaultPackage = $container->getDefinition($packages->getArgument(0));
$this->assertEquals('assets.custom_version_strategy', (string) $defaultPackage->getArgument(1));
}

public function testTranslator()
{
$container = $this->createContainerFromFile('full');
Expand Down Expand Up @@ -575,7 +552,7 @@ private function checkAssetsPackages(ContainerBuilder $container, $legacy = fals

// packages
$packages = $packages->getArgument(1);
$this->assertCount($legacy ? 4 : 5, $packages);
$this->assertCount($legacy ? 5 : 6, $packages);

if (!$legacy) {
$package = $container->getDefinition($packages['images_path']);
Expand All @@ -589,7 +566,10 @@ private function checkAssetsPackages(ContainerBuilder $container, $legacy = fals
$this->assertPathPackage($container, $package, '', '1.0.0', '%%s-%%s');

$package = $container->getDefinition($packages['bar']);
$this->assertUrlPackage($container, $package, array('https://bar2.example.com'), $legacy ? '' : 'SomeVersionScheme', $legacy ? '%%s?%%s' : '%%s?version=%%s');
$this->assertUrlPackage($container, $package, array('https://bar2.example.com'), $legacy ? null : 'SomeVersionScheme', $legacy ? '%%s?%%s' : '%%s?version=%%s');

$this->assertEquals($legacy ? 'assets.empty_version_strategy' : 'assets._version__default', (string) $container->getDefinition('assets._package_bar')->getArgument(1));
$this->assertEquals('assets.empty_version_strategy', (string) $container->getDefinition('assets._package_bar_null_version')->getArgument(1));

$this->assertEquals('assets.custom_version_strategy', (string) $container->getDefinition('assets._package_bar_version_strategy')->getArgument(1));
}
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.
0