>> Why do you set an exception when you tell the response that an exception
occured?
I was just trying several things to make it work.
Usually I forward to the errorController when an access is denied; however
if the resource he tries to access has not been initialized in the Acl, it
may be an exceptional error (bug in the application),
that's why I want to throw an exception in that specific case.
if ( ! $acl->has($resource) ) {
$request->setDispatched(true); // has no effect at all
$this->getResponse()->setException(new
My_Exception_AclResourceNotFound("test")); // just a test
throw new My_Exception_AclResourceNotFound('Page doesn\'t exist.');
}
else if ( ! $acl->isAllowed($role, $resource, $privilege) )
return $request->setModuleName('admin')
->setControllerName('error')
->setActionName('unauthorized')
->setParam('info', 'Access denied.');
Tobias Petry wrote:
>
> Why do you set an exception when you tell the response that an exception
> occured?
> This sounds weird.
>
> You want to disable access to some resources? Forward the request to
> (maybe) ErrorController::aclAction or simply put the json output in the
> response body and setDispatched=true
>
--
View this message in context:
http://www.nabble.com/Proper-way-to-stop-a-request-from-preDispatch---tp25108403p25133634.html
Sent from the Zend Framework mailing list archive at Nabble.com.