Zend Acl - “资源”错误“未找到

发布于 2024-11-07 10:17:35 字数 1970 浏览 0 评论 0原文

当我调用“users”控制器时,它给了我这个错误:

**Fatal error:** Uncaught exception 'Zend_Acl_Exception' with message 'Resource 'error' not found' in /home/zerego/library/Zend/Acl.php:364 
Stack trace: 
 #0 /home/zerego/library/Zend/Acl.php(774): Zend_Acl->get('error') 
 #1 /home/zerego/application/plugins/AccessCheck.php(25): Zend_Acl->isAllowed('normal', 'error', 'error') 
 #2 /home/zerego/library/Zend/Controller/Plugin/Broker.php(309): My_Plugin_AccessCheck->preDispatch(Object(Zend_Controller_Request_Http)) 
 #3 /home/zerego/library/Zend/Controller/Front.php(941): Zend_Controller_Plugin_Broker->preDispatch(Object(Zend_Controller_Request_Http)) 
 #4 /home/zerego/library/Zend/Application/Bootstrap/Bootstrap.php(97): Zend_Controller_Front->dispatch() 
 #5 /home/zerego/library/Zend/Application.php(366): Zend_Application_Bootstrap_Bootstrap->run() 
 #6 /home/zerego/public_html/index.php(26): Zend_Application->run() 
 #7 {main} thrown in /home/zerego/library/Zend/Acl.php on line 364

我的 acl 文档与其他控制器一起工作正常,如下所示:

<?php
$acl = new Zend_Acl();

$roles  = array('admin', 'normal');

// Controller script names. You have to add all of them if credential check
// is global to your application.
$controllers = array('error', 'auth', 'index', 'paginator', 'albums', 'users');

foreach ($roles as $role) {
$acl->addRole(new Zend_Acl_Role($role));
}
foreach ($controllers as $controller) {
$acl->add(new Zend_Acl_Resource($controller));
}

// Here comes credential definiton for admin user.
$acl->allow('admin'); // Has access to everything.

// Here comes credential definition for normal user.
$acl->allow('normal'); // Has access to everything...
$acl->deny('normal', 'albums'); // ... except the admin controller.

// Finally I store whole ACL definition to registry for use
// in AuthPlugin plugin.
$registry = Zend_Registry::getInstance();
$registry->set('acl', $acl);

?>

When I call the "users" controller, it is giving me this error:

**Fatal error:** Uncaught exception 'Zend_Acl_Exception' with message 'Resource 'error' not found' in /home/zerego/library/Zend/Acl.php:364 
Stack trace: 
 #0 /home/zerego/library/Zend/Acl.php(774): Zend_Acl->get('error') 
 #1 /home/zerego/application/plugins/AccessCheck.php(25): Zend_Acl->isAllowed('normal', 'error', 'error') 
 #2 /home/zerego/library/Zend/Controller/Plugin/Broker.php(309): My_Plugin_AccessCheck->preDispatch(Object(Zend_Controller_Request_Http)) 
 #3 /home/zerego/library/Zend/Controller/Front.php(941): Zend_Controller_Plugin_Broker->preDispatch(Object(Zend_Controller_Request_Http)) 
 #4 /home/zerego/library/Zend/Application/Bootstrap/Bootstrap.php(97): Zend_Controller_Front->dispatch() 
 #5 /home/zerego/library/Zend/Application.php(366): Zend_Application_Bootstrap_Bootstrap->run() 
 #6 /home/zerego/public_html/index.php(26): Zend_Application->run() 
 #7 {main} thrown in /home/zerego/library/Zend/Acl.php on line 364

My acl document works fine with the other controllers, and is like this:

<?php
$acl = new Zend_Acl();

$roles  = array('admin', 'normal');

// Controller script names. You have to add all of them if credential check
// is global to your application.
$controllers = array('error', 'auth', 'index', 'paginator', 'albums', 'users');

foreach ($roles as $role) {
$acl->addRole(new Zend_Acl_Role($role));
}
foreach ($controllers as $controller) {
$acl->add(new Zend_Acl_Resource($controller));
}

// Here comes credential definiton for admin user.
$acl->allow('admin'); // Has access to everything.

// Here comes credential definition for normal user.
$acl->allow('normal'); // Has access to everything...
$acl->deny('normal', 'albums'); // ... except the admin controller.

// Finally I store whole ACL definition to registry for use
// in AuthPlugin plugin.
$registry = Zend_Registry::getInstance();
$registry->set('acl', $acl);

?>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

美煞众生 2024-11-14 10:17:35

我找到了答案!

我使用了错误的 Acl 文件。在正确的 Acl 文件中,我没有添加“错误”或“用户”资源。

不管怎样,谢谢你的帮助。 :)

I found the answer !

I was working in the wrong Acl file. In the right Acl file i didn't add the "error" ou "users" resources.

Thanks for the help anyway. :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文