I have an Acl plugin that extends Zend_Controller_Plugin_Abstract, this plugin processes all my Acl code.
I want to throw an exception in this plugin, for example. a Exception_Unauthorised, and then handle this in mine ErrorController, so I can use the same Acl plugin for different applications and use it ErrorControllerto handle each situation in each application differently - if necessary.
The problem is that throwing an Exception from the plugin does not stop the execution of the original Action. This way I get the original Action output and output ErrorController.
How can I get the exception thrown in the plugin to stop the original action?
Case 1
public function preDispatch(Zend_Controller_Request_Abstract $request)
{
parent::preDispatch($request);
throw new Exception_NoPermissions("incorrect permissions");
}
Case 2
public function preDispatch(Zend_Controller_Request_Abstract $request)
{
parent::preDispatch($request);
try
{
throw new Exception_NoPermissions("incorrect permissions");
}
catch(Exception_NoPermissions $e)
{
}
}
3
, , .
public function preDispatch(Zend_Controller_Request_Abstract $request)
{
parent::preDispatch($request);
if(!$loggedIn || !$access)
{
$request->getControllerName("login");
}
}