如果控制器被调用,如果它没有在zend acl中注册那么我们通常会得到像这样的错误
Fatal error: Uncaught exception 'Zend_Acl_Exception' with message
'Resource 'hsfasfdadsf' not found' in /usr/share/php/libzend-framework-php/Zend/Acl.php:365
Stack trace:
#0 /var/www/update/library/Management/Access.php(55): Zend_Acl->get('hsfasfdadsf')
#1 /usr/share/php/libzend-framework-php/Zend/Controller/Plugin/Broker.php(309): Management_Access->preDispatch(Object(Zend_Controller_Request_Http))
#2 /usr/share/php/libzend-framework-php/Zend/Controller/Front.php(941):
是不是有办法检查控制器和操作是否在zend acl中注册,我试过
if(!$acl->get($controller))
{
$request->setControllerName('error');
$request->setActionName('notfound');
}
但没有效果
答案 0 :(得分:6)
避免这些例外,例如
if (!$acl->has($your_resource)) {
// .. handle it the way you need
}
在ErrorController中处理这些异常,即:
if ($errors->exception instanceof Zend_Acl_Exception) {
// send needed headers...
// prepare log message...
// render info: resource_not_found.phtml
$this->_helper->viewRenderer('resource_not_found');
}