Creating a JMS Serializer handler in symfony2
deserialization, json-deserialization, serialization, symfony
Solution
The solution is to create a service with the right tag.
datetimezone_handler:
class: MyVendor\MyBundle\Serializer\Handler\DateTimeZoneHandler
tags:
- { name: jms_serializer.subscribing_handler }
Problem
I tried to follow the related 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'm stuck when trying to get the builder object in symfony2 (see second link for this object). The service is a serializer which has already been build. Where should i instanciate my own handler? Update: I'm investigating one possible solution: `$builder = \JMS\Serializer\SerializerBuilder::create();` or `$builder = new \JMS\Serializer\SerializerBuilder();` maybe this will work but it would be nice to let the already instanciated serializer make use of my handler. To get the serializer service in the controller: `$serializer = $this->get('jms.serializer');`