Page display not found error with zend acl

whenever the controller is called, if it is not registered in zend acl, then we usually get erro r, like this

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):

there is no way to check if the controller and action are registered in zend acl, I tried

if(!$acl->get($controller))
{
    $request->setControllerName('error');
    $request->setActionName('notfound');
}

but does not work

+3
source share
1 answer

First decision:

Avoid these exceptions, e.g.

if (!$acl->has($your_resource)) {
   // .. handle it the way you need
}

Second

Handle these exceptions in the ErrorController, i.e.:

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');
}
+6
source

Source: https://habr.com/ru/post/1788201/


All Articles