diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index 84dbeabe98bdd..83518061fed36 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -1334,6 +1334,10 @@ private function registerAssetMapperConfiguration(array $config, ContainerBuilde { $loader->load('asset_mapper.php'); + if (!$assetEnabled) { + $container->removeDefinition('asset_mapper.asset_package'); + } + if (!$httpClientEnabled) { $container->register('asset_mapper.http_client', HttpClientInterface::class) ->addTag('container.error') diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/asset_mapper_without_assets.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/asset_mapper_without_assets.php new file mode 100644 index 0000000000000..8a74333b19324 --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/asset_mapper_without_assets.php @@ -0,0 +1,10 @@ +loadFromExtension('framework', [ + 'annotations' => false, + 'asset_mapper' => null, + 'assets' => false, + 'handle_all_throwables' => true, + 'http_method_override' => false, + 'php_errors' => ['log' => true], +]); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/asset_mapper_without_assets.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/asset_mapper_without_assets.xml new file mode 100644 index 0000000000000..3976b1064222d --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/asset_mapper_without_assets.xml @@ -0,0 +1,14 @@ + + + + + + + + + + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/asset_mapper_without_assets.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/asset_mapper_without_assets.yml new file mode 100644 index 0000000000000..51f302b668843 --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/asset_mapper_without_assets.yml @@ -0,0 +1,8 @@ +framework: + annotations: false + asset_mapper: ~ + assets: false + handle_all_throwables: true + http_method_override: false + php_errors: + log: true diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTestCase.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTestCase.php index 55de5cc247652..705ec5f3144e3 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTestCase.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTestCase.php @@ -2386,6 +2386,16 @@ public function testWebhookWithoutSerializer() ); } + public function testAssetMapperWithoutAssets() + { + $container = $this->createContainerFromFile('asset_mapper_without_assets'); + + $this->assertTrue($container->has('asset_mapper')); + $this->assertFalse($container->has('asset_mapper.asset_package')); + $this->assertFalse($container->has('assets.packages')); + $this->assertFalse($container->has('assets._default_package')); + } + protected function createContainer(array $data = []) { return new ContainerBuilder(new EnvPlaceholderParameterBag(array_merge([