New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fallback handling of ordinary ....Response objects #26
Comments
Fixing other Bundle is beyond the scope of this Bundle. If you want to JSON-fy 3rd party Bundles I recommend looking at https://github.com/liip/MultiplexBundle |
Really, I don't need multiplexing support. I want transparent output-format-agnostic support. Sorry if it's too much to be asked. |
Maybe I didnt understand your request, but if you want to JSON-ify UserBundle actions, the MultiplexBundle does what you need, since it allows you to define what format you want returned. If you need something else could you maybe come up with a php example? |
I didn't argue that MultiplexBundle wouldn'y give me what I need. Yes, it does. But it feels kind of hacky and certainly not as flexible as it can be. Maybe that's just me. But. But this bundle would give me the support of different serializers and normalizers which would be very nice even And of course since exceptions can be already nicely and automatically converted to suitable format with this bundle I For now the Bundle provides a view layer to enable output format agnostic Controllers, which includes the ability to handle redirects differently based on a service container aware Serializer service that can lazy load encoders and normalizers. This sentence really got me excited and I never thought it only provides this ability when using special View class. I really can see the format conversion for ordinary Responses can be done very efficiently in this bundle Maybe I'm wrong. Maybe I'm missing something. I don't know. |
I still dont get what the RestBundle is supposed to do here. |
Provide a way to match the behavior of ordinary exceptions
for ordinary Responses. Ok, I can provide some example code which maybe could be included in RestBundle but it takes a bit time.
|
I still dont think this should be part of RestBundle, but I guess you can create a Response listener that does something. Still I dont know what the Response listener is supposed to do with the content of the 3rd party bundle. But if you got something you can send a PR and we can discuss further. |
There should be some way to specify that I want all Response objects
returned by actions modified (normalized/serialized) to requested format.
Currently, if action returns Response object (and json format is requested by Accept: header)
the content is thrown at browser as-is, but Content-Type is modifed to reflect requested format.
I mean: content returned to client is html but content-type says it's application/json for example.
I could implement my own onCoreResponse listener to achieve that for my own needs,
but shouldn't this kind of fallback functionality be included in RestBundle?
It's would be mainly useful in cases where I cannot use RestBundle\View (3rd party bundles).
For example FOSUserBundle - it hardcodes responses (and templates used) and this would
give the opportunity to at least convert those responses to format that is meaningfully handleable
by browser app.
Any comments or extra ideas? I don't feel my thoughts regarding this are mature enough at this point.
The text was updated successfully, but these errors were encountered: