2011-06-07 44 views
0

我得到可用的「客人」用戶每查看下面的錯誤爲「guest」用戶這樣做:問題界定什麼在Zend_Acl裏

注意:試圖讓非對象的財產/home/fiodorovich/public_html/gisele/library/Federico/Plugin/Acl.php線路35

它指的是行是「$角色= $這個 - > _ auth-> getStorage() - >閱讀() - >作用;」在:

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'); 
     } 
    } 
} 

我知道這只是一個通知,並且它不會顯示在生產中,因爲錯誤將被禁用......但它是一種糾纏我。那我怎麼解決這個問題?

回答

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; 
} 
+0

非常感謝@KomarSerjio的幫助。 – 2011-06-07 18:42:52