From 9d365dc4fe0456632a130c9cc1500a2ebcb11844 Mon Sep 17 00:00:00 2001 From: Michael Babker Date: Mon, 12 Jun 2023 13:05:45 -0400 Subject: [PATCH] Don't wire the AttributeDriver --- .../JMSSerializerExtension.php | 34 ++++++------------- Resources/config/services.xml | 7 ++-- 2 files changed, 15 insertions(+), 26 deletions(-) diff --git a/DependencyInjection/JMSSerializerExtension.php b/DependencyInjection/JMSSerializerExtension.php index 1d7fa67c..421c8072 100644 --- a/DependencyInjection/JMSSerializerExtension.php +++ b/DependencyInjection/JMSSerializerExtension.php @@ -47,32 +47,17 @@ public function load(array $rawConfigs, ContainerBuilder $container): void $metadataDrivers = [ new Reference('jms_serializer.metadata.yaml_driver'), new Reference('jms_serializer.metadata.xml_driver'), + // new Reference('jms_serializer.metadata.attribute_driver'), // TODO - Re-enable this driver at a later time new Reference('jms_serializer.metadata.annotation_driver'), ]; - // enable the attribute driver on php 8 - if (PHP_VERSION_ID >= 80000) { - if (class_exists(AttributeDriver::class)) { - // Register the attribute driver before the annotation driver - $metadataDrivers = [ - new Reference('jms_serializer.metadata.yaml_driver'), - new Reference('jms_serializer.metadata.xml_driver'), - new Reference('jms_serializer.metadata.attribute_driver'), - new Reference('jms_serializer.metadata.annotation_driver'), - ]; - } else { - $container->removeDefinition('jms_serializer.metadata.attribute_driver'); - - if (class_exists(AttributeReader::class)) { - $container->register('jms_serializer.metadata.annotation_and_attributes_reader', AttributeReader::class) - ->setArgument(0, new Reference('annotation_reader')); - - $container->findDefinition('jms_serializer.metadata.annotation_driver') - ->replaceArgument(0, new Reference('jms_serializer.metadata.annotation_and_attributes_reader')); - } - } - } else { - $container->removeDefinition('jms_serializer.metadata.attribute_driver'); + // enable attributes support on php 8 + if (PHP_VERSION_ID >= 80000 && class_exists(AttributeReader::class)) { + $container->register('jms_serializer.metadata.annotation_and_attributes_reader', AttributeReader::class) + ->setArgument(0, new Reference('annotation_reader')); + + $container->findDefinition('jms_serializer.metadata.annotation_driver') + ->replaceArgument(0, new Reference('jms_serializer.metadata.annotation_and_attributes_reader')); } $container @@ -194,6 +179,8 @@ private function loadInternal(array $config, ScopedContainer $container, array $ ->getDefinition('jms_serializer.metadata.annotation_driver') ->replaceArgument(3, new Reference($config['expression_evaluator']['id'])); + // TODO - Re-enable this driver at a later time + /* try { $container ->getDefinition('jms_serializer.metadata.attribute_driver') @@ -201,6 +188,7 @@ private function loadInternal(array $config, ScopedContainer $container, array $ } catch (ServiceNotFoundException $exception) { // Removed by conditional checks earlier } + */ } } else { $container->removeDefinition('jms_serializer.expression_evaluator'); diff --git a/Resources/config/services.xml b/Resources/config/services.xml index 9ef4b3b6..4bff61a8 100644 --- a/Resources/config/services.xml +++ b/Resources/config/services.xml @@ -113,11 +113,12 @@ NULL - + + - + NULL + --> NULL