2009年2月5日星期四

Re: [fw-mvc] Redirect from a custom route - best option

Thanks Matthew,

I am going to implement this approach.

Cristian
> The router is the wrong place to do this. Routing is simply decomposing
> the request environment into artifacts.
>
> I'd do this within a front controller plugin that operates during
> routeShutdown() instead:
>
> class My_Plugin_RedirectEarly extends Zend_Controller_Plugin_Abstract
> {
> public function routeShutdown(Zend_Controller_Request_Abstract $request)
> {
> if ( /* certain criteria met in request object */) {
> $response = $this->getResponse();
> $response->setRedirect(/*...*/);
> $response->sendResponse();
> exit;
> }
> }
> }
>
> You don't necessarily need to do the sendResponse()/exit there, but it
> gets the point across.
>
>


--
Best regards,
Cristian Bichis
www.zftutorials.com | www.zfforums.com | www.zftalk.com | www.zflinks.com

没有评论: