I need to implement a RESTful API for my symfony 2 site, so I use FOSRestBundle + JMSSerializerBundle
I have a serializer yml like this for my object:
Acme\DemoBundle\Entity\Product: exclusion_policy: ALL accessor_order: custom custom_accessor_order: [id, title] properties: id: expose: true title: expose: true virtual_properties: getMainPhoto: serialized_name: photo
The problem is that getMainPhoto returns me the url to the full size image. I want to preprocess this url before sending a response to the api client, where I can generate a new url to resize such an image. I already have a service in sf2 that can do this work:
$resized_url = $someService->generateResizedUrl($item->getMainPhoto(), 640, 480);
But I do not know how to use this service with JMSSerializer. Maybe there are some callbacks for FOSRestBundle \ JMSSerializerBundle before sending a response?
symfony jmsserializerbundle fosrestbundle
striker Jan 23 '13 at 8:20 2013-01-23 08:20
source share