-- spaun <[EMAIL PROTECTED]> wrote
(on Thursday, 08 November 2007, 04:50 AM -0800):
> Matthew Weier O'Phinney-3 wrote:
> > -- spaun <[EMAIL PROTECTED]> wrote
> > (on Wednesday, 07 November 2007, 10:01 PM -0800):
> > > I think that after any event in dispatch loop of front controller
> > > the redirect flag in response object should be checked, and if set
> > > - loop should stop and redirect should occur.
> > > 
> > > say, i have a front controller plugin. in routeStartup i'm somehow
> > > decided that current request is invalid or make no sense and i'd
> > > like the redirection to occur immediately.
> > > 
> > > Currently this could be done by setting the redirect to response
> > > object and throwing an exception, but this depends on
> > > configuration just way too much, i.e. telling front controller to
> > > throw exceptions will require modifications in bootstrap (at
> > > minimum) to handle this special kind of exceptions.
> > > 
> > > What you think?
> > 
> > Good idea. Please add an issue in the issue tracker for this.
> 
> Sorry, but I just can't fugure out how to add an issue (maybe because it's
> and of day here, not sure)

You may need posting permissions; send an email to [EMAIL PROTECTED] if that
is the case. In the meantime, I've added this issue to the tracker:

    http://framework.zend.com/issues/browse/ZF-2167

In writing it up, however, I see a few options that exist already.

First off, when doing redirects from action controllers, the default is
to redirect immediately (see the Redirector action helper); so, in case
a redirect is set in a controller, you have no issues.

Redirecting from a plugin is slightly different. You can certainly set
the redirect in the response, but if you do, you should not throw an
exception. Instead, do this:

    $response->setRedirect($url)
             ->sendResponse();
    exit;

What I'm thinking, however, is that setRedirect() should, by default,
redirect immediately -- unless a second flag parameter is present
telling it not to. This would give you the desired result, and the
Redirector plugin could easily be modified to take this into account,
keeping it all backwards compatible.

-- 
Matthew Weier O'Phinney
PHP Developer            | [EMAIL PROTECTED]
Zend - The PHP Company   | http://www.zend.com/

Reply via email to