Thanks to visit codestin.com
Credit goes to github.com

Skip to content
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
[Serializer] Remove TranslatableNormalizer service when the Translato…
…r is disabled
  • Loading branch information
Jean-Beru committed Dec 1, 2023
commit 319a0fe6702486919d61b7829a283456129a6ce9
Original file line number Diff line number Diff line change
Expand Up @@ -1938,7 +1938,7 @@ private function registerSerializerConfiguration(array $config, ContainerBuilder
$container->removeDefinition('serializer.mapping.cache_class_metadata_factory');
}

if (!class_exists(Translator::class)) {
if (!$this->readConfigEnabled('translator', $container, $config)) {
$container->removeDefinition('serializer.normalizer.translatable');
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

$container->loadFromExtension('framework', [
'annotations' => false,
'http_method_override' => false,
'handle_all_throwables' => true,
'php_errors' => ['log' => true],
'serializer' => [
'enabled' => true,
],
'translator' => [
'enabled' => false,
],
]);
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" ?>

<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:framework="http://symfony.com/schema/dic/symfony"
xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/symfony https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">

<framework:config secret="s3cr3t" http-method-override="false" handle-all-throwables="true">
<framework:annotations enabled="false" />
<framework:php-errors log="true" />
<framework:serializer enabled="true" />
<framework:translator enabled="false" />
</framework:config>
</container>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
framework:
annotations: false
http_method_override: false
handle_all_throwables: true
php_errors:
log: true
serializer:
enabled: true
translator:
enabled: false
Original file line number Diff line number Diff line change
Expand Up @@ -1501,6 +1501,12 @@ public function testSerializerEnabled()
$this->assertEquals($container->getDefinition('serializer.normalizer.object')->getArgument(6)['max_depth_handler'], new Reference('my.max.depth.handler'));
}

public function testSerializerWithoutTranslator()
{
$container = $this->createContainerFromFile('serializer_without_translator');
$this->assertFalse($container->hasDefinition('serializer.normalizer.translatable'));
}

public function testRegisterSerializerExtractor()
{
$container = $this->createContainerFromFile('full');
Expand Down