Creating a JMS serializer handler in symfony2

I tried to execute the relevant documentation, here:
http://jmsyst.com/libs/serializer/master/configuration
here
http://jmsyst.com/libs/serializer/master/handlers
and here
http://jmsyst.com/bundles/JMSSerializerBundle/master/cookbook/custom_handlers

I am stuck when trying to get a builder in symfony2 (see the second link for this object). A service is a serializer that has already been created. Where should I manage my own handler?

Update:
I am studying one possible solution:
$builder = \JMS\Serializer\SerializerBuilder::create();
or
$builder = new \JMS\Serializer\SerializerBuilder();
it might work, but it would be nice to let the serializer already in use use my handler. To get the serializer service in the controller: $serializer = $this->get('jms.serializer');

+7
serialization symfony deserialization json-deserialization
source share
1 answer

The solution is to create a service with the correct tag.

 datetimezone_handler: class: MyVendor\MyBundle\Serializer\Handler\DateTimeZoneHandler tags: - { name: jms_serializer.subscribing_handler } 
+13
source share

All Articles