I am trying to use a special handler for the JMS Serializer Bundle
class CustomHandler implements SubscribingHandlerInterface { public static function getSubscribingMethods() { return array( array( 'direction' => GraphNavigator::DIRECTION_SERIALIZATION, 'format' => 'json', 'type' => 'integer', 'method' => 'serializeIntToJson', ), ); } public function serializeIntToJson(JsonSerializationVisitor $visitor, $int, array $type, Context $context) { die("GIVE ME SOMETHING"); } }
It does nothing and does not die. This is how I register the handler
$serializer = SerializerBuilder::create() ->configureHandlers(function(HandlerRegistry $registry) { $registry->registerSubscribingHandler(new MyHandler()); }) ->addDefaultHandlers() ->build(); $json = $serializer->serialize($obj, 'json');
My handler is never called, and I cannot manipulate serialization data.
source share