Zend framework 定义如何处理';客人';Zend_Acl中的用户

Zend framework 定义如何处理';客人';Zend_Acl中的用户,zend-framework,zend-auth,zend-acl,Zend Framework,Zend Auth,Zend Acl,对于“来宾”用户可用的每个视图,我都会遇到以下错误: 注意:试图在第35行的/home/fiodorovich/public_html/gisele/library/Federico/Plugin/Acl.php中获取非对象的属性 它所指的行是“$role=$this->\u auth->getStorage()->read()->role;”在: public function preDispatch (Zend_Controller_Request_Abstract $request) {

对于“来宾”用户可用的每个视图,我都会遇到以下错误:

注意:试图在第35行的/home/fiodorovich/public_html/gisele/library/Federico/Plugin/Acl.php中获取非对象的属性

它所指的行是“$role=$this->\u auth->getStorage()->read()->role;”在:

public function preDispatch (Zend_Controller_Request_Abstract $request)
{
    $role = $this->_auth->getStorage()->read()->role;

    if($role === null) {
        $role = self::DEFAULT_ROLE;
    }
    $action = $request->getActionName();
    $controller = $request->getControllerName();
    if($this->_acl->has($controller)) {
        if(!$this->_acl->isAllowed($role, $controller, $action)) {
            $request->setActionName('error');
            $request->setControllerName('error');
        }
    }
}

我知道这只是一个通知,它不会在生产中显示,因为错误将被禁用。。。然而,这让我有点烦。那么我该如何解决这个问题呢?

在从存储器请求数据之前使用
$this->\u auth->hasintity()

if ($this->_auth->hasIdentity()) {
    // user is logged in and we can get role
    $role = $this->_auth->getStorage()->read()->role;  
} else {
    // guest
    $role = self::DEFAULT_ROLE;
}

非常感谢您的帮助@KomarSerjio就是这样。