I tried to execute the relevant documentation, here:http://jmsyst.com/libs/serializer/master/configurationherehttp://jmsyst.com/libs/serializer/master/handlersand herehttp://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');
$builder = \JMS\Serializer\SerializerBuilder::create();
$builder = new \JMS\Serializer\SerializerBuilder();
$serializer = $this->get('jms.serializer');
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 }