0

'guest'ユーザーが利用できるすべてのビューで次のエラーが発生します。

注意:35行目の/home/fiodorovich/public_html/gisele/library/Federico/Plugin/Acl.phpで非オブジェクトのプロパティを取得しようとしています

参照している行は「$role= $ this-> _ 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');
        }
    }
}

これは単なる通知であり、エラーが無効になるため本番環境には表示されないことを私は知っています...しかし、それは私を悩ませています。では、どうすればこれを解決できますか?

4

1 に答える 1

1

$this->_auth->hasIdentity()ストレージからデータを要求する前に使用します。

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;
}
于 2011-06-07T18:34:23.337 に答える