2011-05-14 68 views
2

當我稱之爲‘用戶’控制器,它給我這個錯誤:Zend公司的Acl - 「資源‘錯誤’未找到

**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); 

?> 
+0

好吧,它似乎試圖重定向到錯誤控制器? – Ascherer 2011-05-15 11:06:37

+0

你的插件如何將用戶導向錯誤控制器? – Phil 2011-05-15 12:05:08

回答

0

我找到了答案!

我在錯誤的Acl文件中工作。在正確的Acl文件中,我沒有添加「錯誤」或「用戶」資源。

感謝您的幫助。 :)