Skip to content

Commit

Permalink
Merge pull request #568 from Tobion/patch-1
Browse files Browse the repository at this point in the history
Allow autowiring serializer
  • Loading branch information
goetas committed May 4, 2017
2 parents 8e4e235 + d6b88a4 commit 8e37f49
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Resources/config/services.xml
Expand Up @@ -200,6 +200,8 @@
<service id="jms_serializer.serialization_context_factory" alias="jms_serializer.configured_serialization_context_factory"/>

<service id="jms_serializer" alias="jms_serializer.serializer" /><!-- Preferred Alias -->
<service id="JMS\Serializer\SerializerInterface" alias="jms_serializer.serializer" />
<service id="JMS\Serializer\ArrayTransformerInterface" alias="jms_serializer.serializer" />
<service id="serializer" alias="jms_serializer.serializer" /><!-- Here for BC, may be disabled in the config -->

<!-- expression language components -->
Expand Down
2 changes: 2 additions & 0 deletions Tests/DependencyInjection/JMSSerializerExtensionTest.php
Expand Up @@ -223,6 +223,8 @@ public function testLoad()
$versionedObject = new VersionedObject('foo', 'bar');
$serializer = $container->get('serializer');

$this->assertTrue($container->has('JMS\Serializer\SerializerInterface'), 'Alias should be defined to allow autowiring');
$this->assertTrue($container->has('JMS\Serializer\ArrayTransformerInterface'), 'Alias should be defined to allow autowiring');
// test that all components have been wired correctly
$this->assertEquals(json_encode(array('name' => 'bar')), $serializer->serialize($versionedObject, 'json'));
$this->assertEquals($simpleObject, $serializer->deserialize($serializer->serialize($simpleObject, 'json'), get_class($simpleObject), 'json'));
Expand Down

0 comments on commit 8e37f49

Please sign in to comment.