I want to load My ACL plugin to the application, and just start working with ACL
I follow this tutorial to start learning ACL.
I make like this
class My_ACL extends Zend_Acl {
public function __construct() {
$this->addRole(new Zend_Acl_Role('member'));
$this->addRole(new Zend_Acl_Role('admin'));
//discussions is a module name
$this->add(new Zend_Acl_Resource('discussions'));
//privileges is a module name
$this->add(new Zend_Acl_Resource('privileges'));
//default is a the default mdule
$this->add(new Zend_Acl_Resource('default'));
//allow admin every thing
$this->allow('admin');
//tmp just for testing
$this->allow('member');
}
and in the plugin I delete every thing and just keep an echo statement
class Application_Plugin_Acl extends Zend_Controller_Plugin_Abstract {
private $_acl = null;
public function __construct() {
$this->_acl = new My_ACL();
}
public function preDispatch(Zend_Controller_Request_Abstract $request) {
$role = (Zend_Auth::getInstance()->hasIdentity()) ? 'admin' : 'member';
echo $this->_acl->isAllowed($role, $request->getModuleName() . ':' . $request->getControllerName() . ':' . $request->getActionName());
}
but when I try to access any url for the system this error occur
Fatal error: Uncaught exception 'Zend_Acl_Exception' with message 'Resource 'default:error:error' not found' in
D:\ZendFramework\library\Zend\Controller\Plugin\Broker.php on line 312
( ! ) Zend_Acl_Exception: Resource 'default:error:error' not found in D:\ZendFramework\library\Zend\Acl.php on line 365
}
add this line
after
Basically whenever application error occurs ZF changes request object to module default , error controller and its error action . For that case you have not created any resource .
By doing what I say you will be able to see ‘Application Error’ page which will help you fix the first problem .