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.
Fabien
--
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