On 28.10.2010, at 15:56, Jacob Mather wrote:
>
>
> On Thu, Oct 28, 2010 at 3:51 AM, Jordi Boggiano <[email protected]> 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.
>
> Cheers
>
> --
> Jordi Boggiano
> @seldaek :: http://seld.be/
>
>
> I guess the reason it feels like a problem to me, is then you have a view
> controlling a routing logic rule (i.e. after you add a user, display a new
> form for adding another user).
>
> I know it makes the solution harder to leave redirecting in the controller,
> but to me that simply means the most elegant solution hasn't been found yet.
right now redirect() does:
$this->setContent(sprintf('<html><head><meta http-equiv="refresh"
content="1;url=%s"/></head></html>', htmlspecialchars($url, ENT_QUOTES)));
you can still have a method in the controller for this, but it would use the
template layer:
$this->templates->render('redirect.twig', array('url' => '..', 'status' =>
'..'))
however it would mean that in the case for JSON where you might want to follow
the redirect immediately, you would have to implement that logic inside the
template redirect.json.twig.
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