From 74650610ffc1af9111023a7b9902c2393b07ab60 Mon Sep 17 00:00:00 2001 From: linh Date: Fri, 12 Jun 2020 21:02:14 +0700 Subject: [PATCH] [AssetBundle] Move xml service configuration to php --- .../FrameworkExtension.php | 6 +- .../Resources/config/assets.php | 89 +++++++++++++++++++ .../Resources/config/assets.xml | 59 ------------ 3 files changed, 92 insertions(+), 62 deletions(-) create mode 100644 src/Symfony/Bundle/FrameworkBundle/Resources/config/assets.php delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Resources/config/assets.xml diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index d435e8cf8d6b9..fd4eb5ca55a3b 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -315,7 +315,7 @@ public function load(array $configs, ContainerBuilder $container) throw new LogicException('Asset support cannot be enabled as the Asset component is not installed. Try running "composer require symfony/asset".'); } - $this->registerAssetsConfiguration($config['assets'], $container, $loader); + $this->registerAssetsConfiguration($config['assets'], $container, $phpLoader); } if ($this->messengerConfigEnabled = $this->isConfigEnabled($container, $config['messenger'])) { @@ -990,9 +990,9 @@ private function registerRequestConfiguration(array $config, ContainerBuilder $c } } - private function registerAssetsConfiguration(array $config, ContainerBuilder $container, XmlFileLoader $loader) + private function registerAssetsConfiguration(array $config, ContainerBuilder $container, PhpFileLoader $loader) { - $loader->load('assets.xml'); + $loader->load('assets.php'); if ($config['version_strategy']) { $defaultVersion = new Reference($config['version_strategy']); diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/assets.php b/src/Symfony/Bundle/FrameworkBundle/Resources/config/assets.php new file mode 100644 index 0000000000000..28f7bba6a45fb --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/assets.php @@ -0,0 +1,89 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\DependencyInjection\Loader\Configurator; + +use Symfony\Component\Asset\Context\RequestStackContext; +use Symfony\Component\Asset\Package; +use Symfony\Component\Asset\Packages; +use Symfony\Component\Asset\PathPackage; +use Symfony\Component\Asset\UrlPackage; +use Symfony\Component\Asset\VersionStrategy\EmptyVersionStrategy; +use Symfony\Component\Asset\VersionStrategy\JsonManifestVersionStrategy; +use Symfony\Component\Asset\VersionStrategy\RemoteJsonManifestVersionStrategy; +use Symfony\Component\Asset\VersionStrategy\StaticVersionStrategy; + +return static function (ContainerConfigurator $container) { + $container->parameters() + ->set('asset.request_context.base_path', null) + ->set('asset.request_context.secure', null) + ; + + $container->services() + ->set('assets.packages', Packages::class) + ->args([ + service('assets.empty_package'), + [], + ]) + + ->alias(Packages::class, 'assets.packages') + + ->set('assets.empty_package', Package::class) + ->args([ + service('assets.empty_version_strategy'), + ]) + + ->set('assets.context', RequestStackContext::class) + ->args([ + service('request_stack'), + param('asset.request_context.base_path'), + param('asset.request_context.secure'), + ]) + + ->set('assets.path_package', PathPackage::class) + ->abstract() + ->args([ + abstract_arg('base path'), + abstract_arg('version strategy'), + service('assets.context'), + ]) + + ->set('assets.url_package', UrlPackage::class) + ->abstract() + ->args([ + abstract_arg('base URLs'), + abstract_arg('version strategy'), + service('assets.context'), + ]) + + ->set('assets.static_version_strategy', StaticVersionStrategy::class) + ->abstract() + ->args([ + abstract_arg('version'), + abstract_arg('format'), + ]) + + ->set('assets.empty_version_strategy', EmptyVersionStrategy::class) + + ->set('assets.json_manifest_version_strategy', JsonManifestVersionStrategy::class) + ->abstract() + ->args([ + abstract_arg('manifest path'), + ]) + + ->set('assets.remote_json_manifest_version_strategy', RemoteJsonManifestVersionStrategy::class) + ->abstract() + ->args([ + abstract_arg('manifest url'), + service('http_client'), + ]) + ; +}; diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/assets.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/assets.xml deleted file mode 100644 index 73ec21ab429e0..0000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/assets.xml +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - null - null - - - - - - - - - - - - - - - - - - %asset.request_context.base_path% - %asset.request_context.secure% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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