Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow autowiring serializer #568

Merged
merged 4 commits into from
May 4, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Resources/config/services.xml
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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