On 28.10.2010, at 15:35, Fabien Potencier wrote: > On 10/28/10 3:27 PM, Lukas Kahwe Smith wrote: >> >> On 28.10.2010, at 14:26, Fabien Potencier wrote: >> >>> >>> On 10/28/10 9:51 AM, Jordi Boggiano wrote: >>>> On 27.10.2010 22:48, JMather wrote: >>>>> Personally, I don't think redirects belong in the view logic. >>>> >>>> Well, if you want a clean design it kind of does have to be there. >>>> Redirects are not part of the data, it's what the view "displays" in >>>> reaction to the user action. And as we explained that behavior changes >>>> based on which view you have. Html views typically redirect, async-js >>>> stuff doesn't, and other views like a PDF will want to render different >>>> headers to make you download it, etc. The response should be built by >>>> the view. >>>> >>>> I'm not saying you can't have a smart default view that'll make it >>>> unnecessary to have a specific view class in most cases though. >>>> >>>>> I can't think of a lot of instances where redirects would be useful >>>>> with json, though perhaps that's just my particular coding style >>>>> talking... >>>> >>>> Afaik, a redirect in a json request breaks the request. But it's not >>>> only about json anyway. >>> >>> Keep in mind that Views and Templates are two different things. >>> >>> By default in Symfony2, there is no "View" layer per se. In the controller, >>> you do something (most of the time, you render a template) to create a >>> Response object. >>> >>> But, you can also just pass Model data to a View. The View (most of the >>> time an object) is then responsible for rendering the template, adjusting >>> the response headers, play with the cache, redirecting to somewhere else >>> based on the request, the format, whatever, ... >>> >>> There is no mandatory View layer in Symfony2 because most of the time, you >>> don't need one. But as soon as you want to do more complex things, like >>> supporting different formats, or because you want to share your code with >>> others and make it more customizable, Views are definitely the way to go. >> >> >> Yes, but how useful are 3rd party Bundles that do not support JSON out of >> the box? It seems to me like we need to make sure that _all_ Bundles out of >> the box support (at least in the way of not having to modify/extend a >> controller) JSON output. > > I'm not sure I understand. Many bundles do not need to have JSON support. > Anyway, we can make that a best practice, but we cannot enforce it with code.
Any Bundle that outputs direct HTML needs to be able to just return JSON. This imho includes 90% of all Bundles that will ever get written. With the various approaches I have mentioned it is possible to support this without requiring any additional code in the controller. Again the key thing that needs to happen is: - move redirect() out of the controller - make it possible to swap out the view layer without changing the controller or adding events before and after the controller passes data or when data returns to/from the view layer regards, Lukas Kahwe Smith [email protected] -- If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com You received this message because you are subscribed to the Google Groups "symfony developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/symfony-devs?hl=en
