Skip to content

[FrameworkBundle] object mapper service definition without form #60479

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,14 @@ public function load(array $configs, ContainerBuilder $container): void
$loader->load('mime_type.php');
}

if (ContainerBuilder::willBeAvailable('symfony/object-mapper', ObjectMapperInterface::class, ['symfony/framework-bundle'])) {
$loader->load('object_mapper.php');
$container->registerForAutoconfiguration(TransformCallableInterface::class)
->addTag('object_mapper.transform_callable');
$container->registerForAutoconfiguration(ConditionCallableInterface::class)
->addTag('object_mapper.condition_callable');
}

$container->registerForAutoconfiguration(PackageInterface::class)
->addTag('assets.package');
$container->registerForAutoconfiguration(AssetCompilerInterface::class)
Expand Down Expand Up @@ -880,14 +888,6 @@ private function registerFormConfiguration(array $config, ContainerBuilder $cont
if (!ContainerBuilder::willBeAvailable('symfony/translation', Translator::class, ['symfony/framework-bundle', 'symfony/form'])) {
$container->removeDefinition('form.type_extension.upload.validator');
}

if (ContainerBuilder::willBeAvailable('symfony/object-mapper', ObjectMapperInterface::class, ['symfony/framework-bundle'])) {
$loader->load('object_mapper.php');
$container->registerForAutoconfiguration(TransformCallableInterface::class)
->addTag('object_mapper.transform_callable');
$container->registerForAutoconfiguration(ConditionCallableInterface::class)
->addTag('object_mapper.condition_callable');
}
}

private function registerHttpCacheConfiguration(array $config, ContainerBuilder $container, bool $httpMethodOverride): void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2600,6 +2600,14 @@ public function testJsonStreamerEnabled()
$this->assertTrue($container->has('json_streamer.stream_writer'));
}

public function testObjectMapperEnabled()
{
$container = $this->createContainerFromClosure(function (ContainerBuilder $container) {
$container->loadFromExtension('framework', []);
});
$this->assertTrue($container->has('object_mapper'));
}

protected function createContainer(array $data = [])
{
return new ContainerBuilder(new EnvPlaceholderParameterBag(array_merge([
Expand Down
Loading