feature #16947 [FrameworkBundle] PropertyInfo: register the SerializerExtractor (dunglas)
This PR was squashed before being merged into the 3.1-dev branch (closes #16947).
Discussion
----------
[FrameworkBundle] PropertyInfo: register the SerializerExtractor
| Q | A
| ------------- | ---
| Bug fix? | no
| New feature? | yes
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | n/a
| License | MIT
| Doc PR | n/a
Commits
-------
4422103
[FrameworkBundle] PropertyInfo: register the SerializerExtractor
This commit is contained in:
commit
0bacababd9
@ -31,17 +31,19 @@ class PropertyInfoPass implements CompilerPassInterface
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -55,5 +55,12 @@
|
||||
|
||||
<!-- Name converter -->
|
||||
<service id="serializer.name_converter.camel_case_to_snake_case" class="Symfony\Component\Serializer\NameConverter\CamelCaseToSnakeCaseNameConverter" public="false" />
|
||||
|
||||
<!-- PropertyInfo extractor -->
|
||||
<service id="property_info.serializer_extractor" class="Symfony\Component\PropertyInfo\Extractor\SerializerExtractor" public="false">
|
||||
<argument type="service" id="serializer.mapping.class_metadata_factory" />
|
||||
|
||||
<tag name="property_info.list_extractor" priority="-999" />
|
||||
</service>
|
||||
</services>
|
||||
</container>
|
||||
|
@ -32,7 +32,8 @@ class PropertyInfoPassTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$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 @@ class PropertyInfoPassTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$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();
|
||||
|
||||
|
@ -441,6 +441,18 @@ abstract class FrameworkExtensionTest extends TestCase
|
||||
$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');
|
||||
|
Reference in New Issue
Block a user