Zend框架1,找不到资源'身份验证'

时间:2015-10-26 13:02:00

标签: php zend-framework

我是zend框架的新手。我创建了我的应用程序,但我遇到了问题。 这是我的Model acl类:

class Model_HotelsAcl extends Zend_Acl{ 
public function construct()
{
    $acl = new Zend_Acl();

    //create the user role
    $acl->addRole(new Zend_Acl_Role('user'));
    //create the admin role which inherited all of the user's permissions
    $acl->addRole(new Zend_Acl_Role('admin'), 'user');
    //create the root role which inherited all of the admin's permissions
    $acl->addRole(new Zend_Acl_Role('root'), 'admin');

    //add the resources
    $acl->add(new Zend_Acl_Resource('error'));
    $acl->add(new Zend_Acl_Resource('index'));
    $acl->add(new Zend_Acl_Resource('logout'));

    $acl->add(new Zend_Acl_Resource('user'));
    $acl->add(new Zend_Acl_Resource('edit'),    'user');
    $acl->add(new Zend_Acl_Resource('add'),     'user');
    $acl->add(new Zend_Acl_Resource('delete'),  'user'); 

    $acl->add(new Zend_Acl_Resource('users'));
    $acl->add(new Zend_Acl_Resource('list'),    'users');

    $acl->add(new Zend_Acl_Resource('prices'));
    $acl->add(new Zend_Acl_Resource('list'),    'prices');

    $acl->add(new Zend_Acl_Resource('price'));
    $acl->add(new Zend_Acl_Resource('edit'),    'price');
    $acl->add(new Zend_Acl_Resource('add'),     'price');
    $acl->add(new Zend_Acl_Resource('delete'),  'price');

    $acl->add(new Zend_Acl_Resource('hotel'));
    $acl->add(new Zend_Acl_Resource('edit'),    'hotel');
    $acl->add(new Zend_Acl_Resource('add'),     'hotel');
    $acl->add(new Zend_Acl_Resource('delete'),  'hotel');

    $acl->add(new Zend_Acl_Resource('hotels'));
    $acl->add(new Zend_Acl_Resource('list'),    'hotels');

    $acl->add(new Zend_Acl_Resource('authentication'));
    $acl->add(new Zend_Acl_Resource('login'),   'authentication');
    $acl->add(new Zend_Acl_Resource('logout'),  'authentication');

    //set access rules
    $acl->allow(null, 'login');
    //$acl->allow(null, 'error');

    //user
    $acl->deny('user', array('login', 'users', 'user', 'prices', 'price'));
    $acl->allow('user', array('index', 'logout', 'hotels'));

    //admin
    $acl->allow('admin', 'hotel', 'edit');
    $acl->allow('admin', 'prices', 'edit');

    //root
    $acl->allow('root');
}
}

这是我的bootstrap的initAutoload:

protected function _initAutoload()
{
    $modeLoader = new Zend_Application_Module_Autoloader(array(
                    'namespace' => '',
                    'basePath'  => APPLICATION_PATH));

    $this->_acl = new Model_HotelsAcl;
    $this->_auth = Zend_Auth::getInstance();

    Zend_Debug::dump($this->_auth);

    $fc = Zend_Controller_Front::getInstance();
    $fc->registerPlugin(new Plugin_AccessCheck($this->_acl, $this->_auth));

    return $modeLoader;
}

当我加载页面时,收到以下错误:

Uncaught exception 'Zend_Acl_Exception' with message 'Resource 'authentication' not found'

我找不到我的错误...... 有什么想法吗?

提前致谢! 的Martina

0 个答案:

没有答案