FriendsOfSymfony / FOSRestBundle

This Bundle provides various tools to rapidly develop RESTful API's with Symfony
http://symfony.com/doc/master/bundles/FOSRestBundle/index.html
MIT License
2.79k stars 708 forks source link

Trigger new event to allow updating the response based on view data at one central place #2386

Open stollr opened 1 year ago

stollr commented 1 year ago

Currently it is not easily possible to access the response object and the view at the same time. I have the use case, that I want to return a paginated list of data (using the KnpPaginationBundle) so I pass a pagination wrapper to the view layer.

The response has to contain some meta data (in fact I am using the Link header similar to Githubs API), but I want to do this decoration at one central place and not in each controller. This is currently not possible. So I added a new event that is triggered in the createResponse method of the ViewHandler.

I think this addition could be useful for others, too. So I hope this gets merged.