Skip to content

Commit bc7ceef

Browse files
Merge branch '7.1' into 7.2
* 7.1: (21 commits) [Serializer] [ObjectNormalizer] Use bool filter when FILTER_BOOL is set [HttpClient][Mailer] Revert "Let curl handle transfer encoding", use HTTP/1.1 for Mailgun Reviewed Catalan missing translations [AssetMapper] Upgrade importmap polyfill [HttpClient] Fix initializing InformationalChunk Fix typo: synchronous -> synchronously forward exceptions caught in the AbstractObjectNormalizer [Serializer] Check if exception message in test is correct [Serializer] Check if exception message in test is correct take the new DOM HTMLElement class into account Ibexa is sponsoring Symfony 5.4, thanks to them! \o/ [FrameworkBundle] Fix warming up routes [VarDumper] Fix `FFICaster` test to be platform-adaptable [String] Add `alias` case to `EnglishInflector` [FrameworkBundle] Throw runtime exception when trying to use asset-mapper while http-client is disabled [SecurityBundle] Remove unused memory users’ `name` attribute from the XSD [VarExporter] generate __doUnserialize() method in ProxyHelper::generateLazyProxy() Double check if pcntl function exists Add additional headers in Scaleway bridge [VarDumper] Fix FFI caster test ...
2 parents f4d4715 + 54a84f4 commit bc7ceef

File tree

3 files changed

+16
-14
lines changed

3 files changed

+16
-14
lines changed

DependencyInjection/FrameworkExtension.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ public function load(array $configs, ContainerBuilder $container): void
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
}
@@ -1296,12 +1296,14 @@ private function registerAssetsConfiguration(array $config, ContainerBuilder $co
12961296
}
12971297
}
12981298

1299-
private function registerAssetMapperConfiguration(array $config, ContainerBuilder $container, PhpFileLoader $loader, bool $assetEnabled): void
1299+
private function registerAssetMapperConfiguration(array $config, ContainerBuilder $container, PhpFileLoader $loader, bool $assetEnabled, bool $httpClientEnabled): void
13001300
{
13011301
$loader->load('asset_mapper.php');
13021302

1303-
if (!$assetEnabled) {
1304-
$container->removeDefinition('asset_mapper.asset_package');
1303+
if (!$httpClientEnabled) {
1304+
$container->register('asset_mapper.http_client', HttpClientInterface::class)
1305+
->addTag('container.error')
1306+
->addError('You cannot use the AssetMapper integration since the HttpClient component is not enabled. Try enabling the "framework.http_client" config option.');
13051307
}
13061308

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

Resources/config/asset_mapper.php

Lines 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')->nullOnInvalid()])
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')->nullOnInvalid(),
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')->nullOnInvalid(),
222+
service('asset_mapper.http_client'),
221223
])
222224

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

Routing/Router.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public function getRouteCollection(): RouteCollection
6969
$this->collection->addResource(new ContainerParametersResource($this->collectedParameters));
7070

7171
try {
72-
$containerFile = ($this->paramFetcher)('kernel.cache_dir').'/'.($this->paramFetcher)('kernel.container_class').'.php';
72+
$containerFile = ($this->paramFetcher)('kernel.build_dir').'/'.($this->paramFetcher)('kernel.container_class').'.php';
7373
if (file_exists($containerFile)) {
7474
$this->collection->addResource(new FileResource($containerFile));
7575
} else {
@@ -84,14 +84,12 @@ public function getRouteCollection(): RouteCollection
8484

8585
public function warmUp(string $cacheDir, ?string $buildDir = null): array
8686
{
87-
if (!$buildDir) {
88-
return [];
87+
if (null === $currentDir = $this->getOption('cache_dir')) {
88+
return []; // skip warmUp when router doesn't use cache
8989
}
9090

91-
$currentDir = $this->getOption('cache_dir');
92-
93-
// force cache generation in build_dir
94-
$this->setOption('cache_dir', $buildDir);
91+
// force cache generation
92+
$this->setOption('cache_dir', $buildDir ?? $cacheDir);
9593
$this->getMatcher();
9694
$this->getGenerator();
9795

0 commit comments

Comments
 (0)