Skip to content

Commit 6a6f478

Browse files
committed
minor #37255 [AssetBundle] Move xml service configuration to php (NguyenTruongLinh)
This PR was squashed before being merged into the 5.2-dev branch. Discussion ---------- [AssetBundle] Move xml service configuration to php | Q | A | ------------- | --- | Branch? | master for features / 3.4, 4.4, 5.0 or 5.1 for bug fixes <!-- see below --> | Bug fix? | yes/no | New feature? | yes/no <!-- please update src/**/CHANGELOG.md files --> | Deprecations? | yes/no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tickets | Fix #... <!-- prefix each issue number with "Fix #", if any --> | License | MIT | Doc PR | symfony/symfony-docs#... <!-- required for new features --> <!-- Replace this notice by a short README for your feature/bugfix. This will help people understand your PR and can be used as a start for the documentation. Additionally (see https://symfony.com/releases): - Always add tests and ensure they pass. - Never break backward compatibility (see https://symfony.com/bc). - Bug fixes must be submitted against the lowest maintained branch where they apply (lowest branches are regularly merged to upper ones so they get the fixes too.) - Features and deprecations must be submitted against branch master. --> Commits ------- 7465061 [AssetBundle] Move xml service configuration to php
2 parents 6f6e4ce + 7465061 commit 6a6f478

File tree

3 files changed

+92
-62
lines changed

3 files changed

+92
-62
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ public function load(array $configs, ContainerBuilder $container)
315315
throw new LogicException('Asset support cannot be enabled as the Asset component is not installed. Try running "composer require symfony/asset".');
316316
}
317317

318-
$this->registerAssetsConfiguration($config['assets'], $container, $loader);
318+
$this->registerAssetsConfiguration($config['assets'], $container, $phpLoader);
319319
}
320320

321321
if ($this->messengerConfigEnabled = $this->isConfigEnabled($container, $config['messenger'])) {
@@ -990,9 +990,9 @@ private function registerRequestConfiguration(array $config, ContainerBuilder $c
990990
}
991991
}
992992

993-
private function registerAssetsConfiguration(array $config, ContainerBuilder $container, XmlFileLoader $loader)
993+
private function registerAssetsConfiguration(array $config, ContainerBuilder $container, PhpFileLoader $loader)
994994
{
995-
$loader->load('assets.xml');
995+
$loader->load('assets.php');
996996

997997
if ($config['version_strategy']) {
998998
$defaultVersion = new Reference($config['version_strategy']);
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
13+
14+
use Symfony\Component\Asset\Context\RequestStackContext;
15+
use Symfony\Component\Asset\Package;
16+
use Symfony\Component\Asset\Packages;
17+
use Symfony\Component\Asset\PathPackage;
18+
use Symfony\Component\Asset\UrlPackage;
19+
use Symfony\Component\Asset\VersionStrategy\EmptyVersionStrategy;
20+
use Symfony\Component\Asset\VersionStrategy\JsonManifestVersionStrategy;
21+
use Symfony\Component\Asset\VersionStrategy\RemoteJsonManifestVersionStrategy;
22+
use Symfony\Component\Asset\VersionStrategy\StaticVersionStrategy;
23+
24+
return static function (ContainerConfigurator $container) {
25+
$container->parameters()
26+
->set('asset.request_context.base_path', null)
27+
->set('asset.request_context.secure', null)
28+
;
29+
30+
$container->services()
31+
->set('assets.packages', Packages::class)
32+
->args([
33+
service('assets.empty_package'),
34+
[],
35+
])
36+
37+
->alias(Packages::class, 'assets.packages')
38+
39+
->set('assets.empty_package', Package::class)
40+
->args([
41+
service('assets.empty_version_strategy'),
42+
])
43+
44+
->set('assets.context', RequestStackContext::class)
45+
->args([
46+
service('request_stack'),
47+
param('asset.request_context.base_path'),
48+
param('asset.request_context.secure'),
49+
])
50+
51+
->set('assets.path_package', PathPackage::class)
52+
->abstract()
53+
->args([
54+
abstract_arg('base path'),
55+
abstract_arg('version strategy'),
56+
service('assets.context'),
57+
])
58+
59+
->set('assets.url_package', UrlPackage::class)
60+
->abstract()
61+
->args([
62+
abstract_arg('base URLs'),
63+
abstract_arg('version strategy'),
64+
service('assets.context'),
65+
])
66+
67+
->set('assets.static_version_strategy', StaticVersionStrategy::class)
68+
->abstract()
69+
->args([
70+
abstract_arg('version'),
71+
abstract_arg('format'),
72+
])
73+
74+
->set('assets.empty_version_strategy', EmptyVersionStrategy::class)
75+
76+
->set('assets.json_manifest_version_strategy', JsonManifestVersionStrategy::class)
77+
->abstract()
78+
->args([
79+
abstract_arg('manifest path'),
80+
])
81+
82+
->set('assets.remote_json_manifest_version_strategy', RemoteJsonManifestVersionStrategy::class)
83+
->abstract()
84+
->args([
85+
abstract_arg('manifest url'),
86+
service('http_client'),
87+
])
88+
;
89+
};

src/Symfony/Bundle/FrameworkBundle/Resources/config/assets.xml

Lines changed: 0 additions & 59 deletions
This file was deleted.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy