Skip to content

Commit 0ff288d

Browse files
bug #60479 [FrameworkBundle] object mapper service definition without form (soyuka)
This PR was merged into the 7.3 branch. Discussion ---------- [FrameworkBundle] object mapper service definition without form | Q | A | ------------- | --- | Branch? | 7.3 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | (reported on slack) | License | MIT The object mapper definition was loaded only if forms are used. Commits ------- 82d7ecdec3f [FrameworkBundle] object mapper service definition without form
2 parents 828e3a7 + 95c9a2c commit 0ff288d

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

DependencyInjection/FrameworkExtension.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -642,6 +642,14 @@ public function load(array $configs, ContainerBuilder $container): void
642642
$loader->load('mime_type.php');
643643
}
644644

645+
if (ContainerBuilder::willBeAvailable('symfony/object-mapper', ObjectMapperInterface::class, ['symfony/framework-bundle'])) {
646+
$loader->load('object_mapper.php');
647+
$container->registerForAutoconfiguration(TransformCallableInterface::class)
648+
->addTag('object_mapper.transform_callable');
649+
$container->registerForAutoconfiguration(ConditionCallableInterface::class)
650+
->addTag('object_mapper.condition_callable');
651+
}
652+
645653
$container->registerForAutoconfiguration(PackageInterface::class)
646654
->addTag('assets.package');
647655
$container->registerForAutoconfiguration(AssetCompilerInterface::class)
@@ -880,14 +888,6 @@ private function registerFormConfiguration(array $config, ContainerBuilder $cont
880888
if (!ContainerBuilder::willBeAvailable('symfony/translation', Translator::class, ['symfony/framework-bundle', 'symfony/form'])) {
881889
$container->removeDefinition('form.type_extension.upload.validator');
882890
}
883-
884-
if (ContainerBuilder::willBeAvailable('symfony/object-mapper', ObjectMapperInterface::class, ['symfony/framework-bundle'])) {
885-
$loader->load('object_mapper.php');
886-
$container->registerForAutoconfiguration(TransformCallableInterface::class)
887-
->addTag('object_mapper.transform_callable');
888-
$container->registerForAutoconfiguration(ConditionCallableInterface::class)
889-
->addTag('object_mapper.condition_callable');
890-
}
891891
}
892892

893893
private function registerHttpCacheConfiguration(array $config, ContainerBuilder $container, bool $httpMethodOverride): void

Tests/DependencyInjection/FrameworkExtensionTestCase.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2611,6 +2611,14 @@ public function testJsonStreamerEnabled()
26112611
$this->assertTrue($container->has('json_streamer.stream_writer'));
26122612
}
26132613

2614+
public function testObjectMapperEnabled()
2615+
{
2616+
$container = $this->createContainerFromClosure(function (ContainerBuilder $container) {
2617+
$container->loadFromExtension('framework', []);
2618+
});
2619+
$this->assertTrue($container->has('object_mapper'));
2620+
}
2621+
26142622
protected function createContainer(array $data = [])
26152623
{
26162624
return new ContainerBuilder(new EnvPlaceholderParameterBag(array_merge([

0 commit comments

Comments
 (0)