3

コントローラーが 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');
}

しかし、うまくいきませんでした

4

1 に答える 1

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');
}
于 2011-01-27T19:46:03.173 に答える