2009年6月12日星期五

Re: [fw-mvc] Preventing controller dispatch from a from plugin.

Hi,
Having this issue too, I subclassed both the dispatcher & response object to add a simple 'skip_dispatch_loop' flag.
(by the way, I used getter & setter, for the recent debate :) )
Remy

On Thu, Jun 11, 2009 at 2:54 PM, Benjamin Radtke <radtke@digitalzone.de> wrote:
Емил Иванов / Emil Ivanov schrieb:
Hi all,

I'm writing an auth plugin that should redirect the user to the login
page if she is not logged in. After the call to
Zend_Controller_Action_Helper_Redirector::gotoUrl the controller
action gets called anyway.
Calling gotoUrlAndExit() is not an options since it will kill the unit
tests interpreter.

I dug into the code, but couldn't find a way to stop the action from
being called.

Regards

 
Hi, this is the Way I did:

class My_Plugin_AccessControl extends Zend_Controller_Plugin_Abstract
{
  public function dispatchLoopStartup(Zend_Controller_Request_Abstract $request)
  {
      if (!Zend_Auth::getInstance()->hasIdentity()) {
          $request->setModuleName('user')->setControllerName('auth')->setActionName('login')->setDispatched(true);
      }
  }
}

Benjamin

没有评论: