Skip to content

Commit

Permalink
do not decorate the jms handler registry for jms v4
Browse files Browse the repository at this point in the history
  • Loading branch information
goetas committed Oct 14, 2021
1 parent f2904a9 commit aa38360
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class HandlerRegistryDecorationPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container): void
{
// skip if JMSSerializerBundle is not installed or if JMSSerializerBundle >= 4.0
if (!$container->has('fos_rest.serializer.jms_handler_registry') || $container->has('jms_serializer.handler_registry.service_locator')) {
return;
}
Expand Down

This file was deleted.

2 changes: 0 additions & 2 deletions FOSRestBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use FOS\RestBundle\DependencyInjection\Compiler\ConfigurationCheckPass;
use FOS\RestBundle\DependencyInjection\Compiler\HandlerRegistryDecorationPass;
use FOS\RestBundle\DependencyInjection\Compiler\JMSFormErrorHandlerPass;
use FOS\RestBundle\DependencyInjection\Compiler\JMSHandlerRegistryV4DecorationPass;
use FOS\RestBundle\DependencyInjection\Compiler\JMSHandlersPass;
use FOS\RestBundle\DependencyInjection\Compiler\FormatListenerRulesPass;
use FOS\RestBundle\DependencyInjection\Compiler\SerializerConfigurationPass;
Expand All @@ -40,7 +39,6 @@ public function build(ContainerBuilder $container)
$container->addCompilerPass(new FormatListenerRulesPass());
$container->addCompilerPass(new JMSFormErrorHandlerPass());
$container->addCompilerPass(new JMSHandlersPass(), PassConfig::TYPE_BEFORE_REMOVING, -10);
$container->addCompilerPass(new JMSHandlerRegistryV4DecorationPass());
$container->addCompilerPass(new HandlerRegistryDecorationPass(), PassConfig::TYPE_AFTER_REMOVING);
}
}
5 changes: 5 additions & 0 deletions Tests/Functional/DependencyInjectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use FOS\RestBundle\Serializer\JMSHandlerRegistryV2;
use FOS\RestBundle\Serializer\Normalizer\FormErrorHandler;
use JMS\Serializer\Visitor\SerializationVisitorInterface;
use JMS\SerializerBundle\Debug\TraceableHandlerRegistry;
use JMS\SerializerBundle\JMSSerializerBundle;
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
Expand All @@ -33,6 +34,10 @@ public function testSerializerRelatedServicesAreNotRemovedWhenJmsSerializerBundl

$this->assertInstanceOf(FormErrorHandler::class, $container->get('test.jms_serializer.form_error_handler'));

if (class_exists(TraceableHandlerRegistry::class)) {
$this->markTestIncomplete('Starting from jms/serializer-bundle 4.0 the handler registry is not decorated anymore');
}

$this->assertInstanceOf(
interface_exists(SerializationVisitorInterface::class) ? JMSHandlerRegistryV2::class : JMSHandlerRegistry::class,
$container->get('test.jms_serializer.handler_registry')
Expand Down

0 comments on commit aa38360

Please sign in to comment.