Skip to content

Navigation Menu

Sign in
Appearance settings

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 c1d1cb0

Browse filesBrowse files
[FrameworkBundle] Throw runtime exception when trying to use asset-mapper while http-client is disabled
1 parent b3a0478 commit c1d1cb0
Copy full SHA for c1d1cb0

File tree

Expand file treeCollapse file tree

2 files changed

+11
-7
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+11
-7
lines changed

‎DependencyInjection/FrameworkExtension.php

Copy file name to clipboardExpand all lines: DependencyInjection/FrameworkExtension.php
+6-4Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ public function load(array $configs, ContainerBuilder $container)
349349
throw new LogicException('AssetMapper support cannot be enabled as the AssetMapper component is not installed. Try running "composer require symfony/asset-mapper".');
350350
}
351351

352-
$this->registerAssetMapperConfiguration($config['asset_mapper'], $container, $loader, $this->readConfigEnabled('assets', $container, $config['assets']));
352+
$this->registerAssetMapperConfiguration($config['asset_mapper'], $container, $loader, $this->readConfigEnabled('assets', $container, $config['assets']), $this->readConfigEnabled('http_client', $container, $config['http_client']));
353353
} else {
354354
$container->removeDefinition('cache.asset_mapper');
355355
}
@@ -1330,12 +1330,14 @@ private function registerAssetsConfiguration(array $config, ContainerBuilder $co
13301330
}
13311331
}
13321332

1333-
private function registerAssetMapperConfiguration(array $config, ContainerBuilder $container, PhpFileLoader $loader, bool $assetEnabled): void
1333+
private function registerAssetMapperConfiguration(array $config, ContainerBuilder $container, PhpFileLoader $loader, bool $assetEnabled, bool $httpClientEnabled): void
13341334
{
13351335
$loader->load('asset_mapper.php');
13361336

1337-
if (!$assetEnabled) {
1338-
$container->removeDefinition('asset_mapper.asset_package');
1337+
if (!$httpClientEnabled) {
1338+
$container->register('asset_mapper.http_client', HttpClientInterface::class)
1339+
->addTag('container.error')
1340+
->addError('You cannot use the AssetMapper integration since the HttpClient component is not enabled. Try enabling the "framework.http_client" config option.');
13391341
}
13401342

13411343
$paths = $config['paths'];

‎Resources/config/asset_mapper.php

Copy file name to clipboardExpand all lines: Resources/config/asset_mapper.php
+5-3Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@
5454
])
5555
->alias(AssetMapperInterface::class, 'asset_mapper')
5656

57+
->alias('asset_mapper.http_client', 'http_client')
58+
5759
->set('asset_mapper.mapped_asset_factory', MappedAssetFactory::class)
5860
->args([
5961
service('asset_mapper.public_assets_path_resolver'),
@@ -197,7 +199,7 @@
197199
])
198200

199201
->set('asset_mapper.importmap.resolver', JsDelivrEsmResolver::class)
200-
->args([service('http_client')])
202+
->args([service('asset_mapper.http_client')])
201203

202204
->set('asset_mapper.importmap.renderer', ImportMapRenderer::class)
203205
->args([
@@ -212,12 +214,12 @@
212214
->set('asset_mapper.importmap.auditor', ImportMapAuditor::class)
213215
->args([
214216
service('asset_mapper.importmap.config_reader'),
215-
service('http_client'),
217+
service('asset_mapper.http_client'),
216218
])
217219
->set('asset_mapper.importmap.update_checker', ImportMapUpdateChecker::class)
218220
->args([
219221
service('asset_mapper.importmap.config_reader'),
220-
service('http_client'),
222+
service('asset_mapper.http_client'),
221223
])
222224

223225
->set('asset_mapper.importmap.command.require', ImportMapRequireCommand::class)

0 commit comments

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