From 4422103a9a15701bfcb10410ab1e3ff0743155c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Thu, 10 Dec 2015 15:53:36 +0100 Subject: [PATCH] [FrameworkBundle] PropertyInfo: register the SerializerExtractor --- .../Compiler/PropertyInfoPass.php | 10 ++++++---- .../FrameworkBundle/Resources/config/serializer.xml | 7 +++++++ .../Compiler/PropertyInfoPassTest.php | 9 ++++++--- .../DependencyInjection/FrameworkExtensionTest.php | 12 ++++++++++++ 4 files changed, 31 insertions(+), 7 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/PropertyInfoPass.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/PropertyInfoPass.php index 819827ac8c38..f2a92021e928 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/PropertyInfoPass.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/PropertyInfoPass.php @@ -31,17 +31,19 @@ public function process(ContainerBuilder $container) return; } + $definition = $container->getDefinition('property_info'); + $listExtractors = $this->findAndSortTaggedServices('property_info.list_extractor', $container); - $container->getDefinition('property_info')->replaceArgument(0, $listExtractors); + $definition->replaceArgument(0, $listExtractors); $typeExtractors = $this->findAndSortTaggedServices('property_info.type_extractor', $container); - $container->getDefinition('property_info')->replaceArgument(1, $typeExtractors); + $definition->replaceArgument(1, $typeExtractors); $descriptionExtractors = $this->findAndSortTaggedServices('property_info.description_extractor', $container); - $container->getDefinition('property_info')->replaceArgument(2, $descriptionExtractors); + $definition->replaceArgument(2, $descriptionExtractors); $accessExtractors = $this->findAndSortTaggedServices('property_info.access_extractor', $container); - $container->getDefinition('property_info')->replaceArgument(3, $accessExtractors); + $definition->replaceArgument(3, $accessExtractors); } /** diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/serializer.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/serializer.xml index d514a3666faa..752588c37e7e 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/serializer.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/serializer.xml @@ -55,5 +55,12 @@ + + + + + + + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/PropertyInfoPassTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/PropertyInfoPassTest.php index 74f0b607bda3..fca0f3461ff8 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/PropertyInfoPassTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/PropertyInfoPassTest.php @@ -32,7 +32,8 @@ public function testServicesAreOrderedAccordingToPriority() $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerBuilder', array('findTaggedServiceIds')); - $container->expects($this->any()) + $container + ->expects($this->any()) ->method('findTaggedServiceIds') ->will($this->returnValue($services)); @@ -53,9 +54,11 @@ public function testReturningEmptyArrayWhenNoService() { $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerBuilder', array('findTaggedServiceIds')); - $container->expects($this->any()) + $container + ->expects($this->any()) ->method('findTaggedServiceIds') - ->will($this->returnValue(array())); + ->will($this->returnValue(array())) + ; $propertyInfoPass = new PropertyInfoPass(); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php index 34889a13a17c..010b62ad7aea 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php @@ -441,6 +441,18 @@ public function testSerializerEnabled() $this->assertEquals(new Reference('serializer.name_converter.camel_case_to_snake_case'), $container->getDefinition('serializer.normalizer.object')->getArgument(1)); } + public function testRegisterSerializerExtractor() + { + $container = $this->createContainerFromFile('full'); + + $serializerExtractorDefinition = $container->getDefinition('property_info.serializer_extractor'); + + $this->assertEquals('serializer.mapping.class_metadata_factory', $serializerExtractorDefinition->getArgument(0)->__toString()); + $this->assertFalse($serializerExtractorDefinition->isPublic()); + $tag = $serializerExtractorDefinition->getTag('property_info.list_extractor'); + $this->assertEquals(array('priority' => -999), $tag[0]); + } + public function testAssetHelperWhenAssetsAreEnabled() { $container = $this->createContainerFromFile('full');