Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 8e3c79b

Browse filesBrowse files
committed
Handle URL in json_manifest_path
1 parent 7277186 commit 8e3c79b
Copy full SHA for 8e3c79b

File tree

7 files changed

+24
-54
lines changed
Filter options

7 files changed

+24
-54
lines changed

‎src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php
-38Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,6 @@ private function addAssetsSection(ArrayNodeDefinition $rootNode)
585585
->scalarNode('version')->defaultNull()->end()
586586
->scalarNode('version_format')->defaultValue('%%s?%%s')->end()
587587
->scalarNode('json_manifest_path')->defaultNull()->end()
588-
->scalarNode('json_manifest_url')->defaultNull()->end()
589588
->scalarNode('base_path')->defaultValue('')->end()
590589
->arrayNode('base_urls')
591590
->requiresAtLeastOneElement()
@@ -611,24 +610,6 @@ private function addAssetsSection(ArrayNodeDefinition $rootNode)
611610
})
612611
->thenInvalid('You cannot use both "version" and "json_manifest_path" at the same time under "assets".')
613612
->end()
614-
->validate()
615-
->ifTrue(function ($v) {
616-
return isset($v['version_strategy']) && isset($v['json_manifest_url']);
617-
})
618-
->thenInvalid('You cannot use both "version_strategy" and "json_manifest_url" at the same time under "assets" packages.')
619-
->end()
620-
->validate()
621-
->ifTrue(function ($v) {
622-
return isset($v['version']) && isset($v['json_manifest_url']);
623-
})
624-
->thenInvalid('You cannot use both "version" and "json_manifest_url" at the same time under "assets" packages.')
625-
->end()
626-
->validate()
627-
->ifTrue(function ($v) {
628-
return isset($v['json_manifest_path']) && isset($v['json_manifest_url']);
629-
})
630-
->thenInvalid('You cannot use both "json_manifest_path" and "json_manifest_url" at the same time under "assets" packages.')
631-
->end()
632613
->fixXmlConfig('package')
633614
->children()
634615
->arrayNode('packages')
@@ -646,7 +627,6 @@ private function addAssetsSection(ArrayNodeDefinition $rootNode)
646627
->end()
647628
->scalarNode('version_format')->defaultNull()->end()
648629
->scalarNode('json_manifest_path')->defaultNull()->end()
649-
->scalarNode('json_manifest_url')->defaultNull()->end()
650630
->scalarNode('base_path')->defaultValue('')->end()
651631
->arrayNode('base_urls')
652632
->requiresAtLeastOneElement()
@@ -672,24 +652,6 @@ private function addAssetsSection(ArrayNodeDefinition $rootNode)
672652
})
673653
->thenInvalid('You cannot use both "version" and "json_manifest_path" at the same time under "assets" packages.')
674654
->end()
675-
->validate()
676-
->ifTrue(function ($v) {
677-
return isset($v['version_strategy']) && isset($v['json_manifest_url']);
678-
})
679-
->thenInvalid('You cannot use both "version_strategy" and "json_manifest_url" at the same time under "assets" packages.')
680-
->end()
681-
->validate()
682-
->ifTrue(function ($v) {
683-
return isset($v['version']) && isset($v['json_manifest_url']);
684-
})
685-
->thenInvalid('You cannot use both "version" and "json_manifest_url" at the same time under "assets" packages.')
686-
->end()
687-
->validate()
688-
->ifTrue(function ($v) {
689-
return isset($v['json_manifest_path']) && isset($v['json_manifest_url']);
690-
})
691-
->thenInvalid('You cannot use both "json_manifest_path" and "json_manifest_url" at the same time under "assets" packages.')
692-
->end()
693655
->end()
694656
->end()
695657
->end()

‎src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
+11-14Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -980,7 +980,7 @@ private function registerAssetsConfiguration(array $config, ContainerBuilder $co
980980
if ($config['version_strategy']) {
981981
$defaultVersion = new Reference($config['version_strategy']);
982982
} else {
983-
$defaultVersion = $this->createVersion($container, $config['version'], $config['version_format'], $config['json_manifest_path'], $config['json_manifest_url'], '_default');
983+
$defaultVersion = $this->createVersion($container, $config['version'], $config['version_format'], $config['json_manifest_path'], '_default');
984984
}
985985

986986
$defaultPackage = $this->createPackageDefinition($config['base_path'], $config['base_urls'], $defaultVersion);
@@ -990,14 +990,14 @@ private function registerAssetsConfiguration(array $config, ContainerBuilder $co
990990
foreach ($config['packages'] as $name => $package) {
991991
if (null !== $package['version_strategy']) {
992992
$version = new Reference($package['version_strategy']);
993-
} elseif (!\array_key_exists('version', $package) && null === $package['json_manifest_path'] && null === $package['json_manifest_url']) {
994-
// if neither version nor json_manifest_path nor json_manifest_url are specified, use the default
993+
} elseif (!\array_key_exists('version', $package) && null === $package['json_manifest_path']) {
994+
// if neither version nor json_manifest_path are specified, use the default
995995
$version = $defaultVersion;
996996
} else {
997997
// let format fallback to main version_format
998998
$format = $package['version_format'] ?: $config['version_format'];
999999
$version = isset($package['version']) ? $package['version'] : null;
1000-
$version = $this->createVersion($container, $version, $format, $package['json_manifest_path'], $package['json_manifest_url'], $name);
1000+
$version = $this->createVersion($container, $version, $format, $package['json_manifest_path'], $name);
10011001
}
10021002

10031003
$container->setDefinition('assets._package_'.$name, $this->createPackageDefinition($package['base_path'], $package['base_urls'], $version));
@@ -1030,7 +1030,7 @@ private function createPackageDefinition(?string $basePath, array $baseUrls, Ref
10301030
return $package;
10311031
}
10321032

1033-
private function createVersion(ContainerBuilder $container, ?string $version, ?string $format, ?string $jsonManifestPath, ?string $jsonManifestUrl, string $name): Reference
1033+
private function createVersion(ContainerBuilder $container, ?string $version, ?string $format, ?string $jsonManifestPath, string $name): Reference
10341034
{
10351035
// Configuration prevents $version and $jsonManifestPath from being set
10361036
if (null !== $version) {
@@ -1045,16 +1045,13 @@ private function createVersion(ContainerBuilder $container, ?string $version, ?s
10451045
}
10461046

10471047
if (null !== $jsonManifestPath) {
1048-
$def = new ChildDefinition('assets.json_manifest_version_strategy');
1049-
$def->replaceArgument(0, $jsonManifestPath);
1050-
$container->setDefinition('assets._version_'.$name, $def);
1051-
1052-
return new Reference('assets._version_'.$name);
1053-
}
1048+
$definitionName = 'assets.json_manifest_version_strategy';
1049+
if ('http' === substr(parse_url($jsonManifestPath, \PHP_URL_SCHEME), 0, 4)) {
1050+
$definitionName = 'assets.remote_json_manifest_version_strategy';
1051+
}
10541052

1055-
if (null !== $jsonManifestUrl) {
1056-
$def = new ChildDefinition('assets.remote_json_manifest_version_strategy');
1057-
$def->replaceArgument(0, $jsonManifestUrl);
1053+
$def = new ChildDefinition($definitionName);
1054+
$def->replaceArgument(0, $jsonManifestPath);
10581055
$container->setDefinition('assets._version_'.$name, $def);
10591056

10601057
return new Reference('assets._version_'.$name);

‎src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/assets.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/assets.php
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
'json_manifest_strategy' => [
2828
'json_manifest_path' => '/path/to/manifest.json',
2929
],
30+
'remote_manifest' => [
31+
'json_manifest_path' => 'https://cdn.example.com/manifest.json',
32+
],
3033
],
3134
],
3235
]);

‎src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/assets.xml

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/assets.xml
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
<framework:base-url>https://bar_version_strategy.example.com</framework:base-url>
2323
</framework:package>
2424
<framework:package name="json_manifest_strategy" json-manifest-path="/path/to/manifest.json" />
25+
<framework:package name="remote_manifest" json-manifest-path="https://cdn.example.com/manifest.json" />
2526
</framework:assets>
2627
</framework:config>
2728
</container>

‎src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/assets.yml

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/assets.yml
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,5 @@ framework:
1919
version_strategy: assets.custom_version_strategy
2020
json_manifest_strategy:
2121
json_manifest_path: '/path/to/manifest.json'
22+
remote_manifest:
23+
json_manifest_path: 'https://cdn.example.com/manifest.json'

‎src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php
+6-1Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ public function testAssets()
535535

536536
// packages
537537
$packages = $packages->getArgument(1);
538-
$this->assertCount(6, $packages);
538+
$this->assertCount(7, $packages);
539539

540540
$package = $container->getDefinition((string) $packages['images_path']);
541541
$this->assertPathPackage($container, $package, '/foo', 'SomeVersionScheme', '%%s?version=%%s');
@@ -556,6 +556,11 @@ public function testAssets()
556556
$versionStrategy = $container->getDefinition((string) $package->getArgument(1));
557557
$this->assertEquals('assets.json_manifest_version_strategy', $versionStrategy->getParent());
558558
$this->assertEquals('/path/to/manifest.json', $versionStrategy->getArgument(0));
559+
560+
$package = $container->getDefinition((string) $packages['remote_manifest']);
561+
$versionStrategy = $container->getDefinition((string) $package->getArgument(1));
562+
$this->assertEquals('assets.remote_json_manifest_version_strategy', $versionStrategy->getParent());
563+
$this->assertEquals('https://cdn.example.com/manifest.json', $versionStrategy->getArgument(0));
559564
}
560565

561566
public function testAssetsDefaultVersionStrategyAsService()

‎src/Symfony/Bundle/FrameworkBundle/composer.json

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/composer.json
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"require-dev": {
3333
"doctrine/annotations": "~1.7",
3434
"doctrine/cache": "~1.0",
35-
"symfony/asset": "^4.4|^5.0",
35+
"symfony/asset": "^5.1",
3636
"symfony/browser-kit": "^4.4|^5.0",
3737
"symfony/console": "^4.4|^5.0",
3838
"symfony/css-selector": "^4.4|^5.0",

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.