我有一个错误,实际上这是错误通知,但我仍然想修复它;
当我尝试使用 访问页面时null role
,它显示以下消息:
Notice: Trying to get property of non-object in C:\Zend\Apache2\htdocs\hotelrwanda\application\plugin\AccessCheck.php on line 18
如何在这里修复它是我的脚本:
public function preDispatch(Zend_Controller_Request_Abstract $request) {
$resource = $request->getControllerName();
$action = $request->getActionName();
$identity = $this->_auth->getStorage()->read();
$role = $identity->role;
if(!$this->_acl->isAllowed($role, $resource, $action)){
$request->setControllerName('users')
->setActionName('login');
}
}
行:18 是这一行:$role = $identity->role;