2011-10-20 117 views
2

該項目使用CakePHP,1.3不能升級項目的CakePHP-2.0

現在我想要升級到CakePHP的-2.0

我已經改名爲所有控制器和模式CakePHP的開發-2.0公約。

現在,如果我重新載入我的錯誤是這樣的頁面:

Indirect modification of overloaded property PostsController::$Auth has no effect [APP/Controller/PostsController.php, line 11] 

代碼:

PostsController:

$this->Auth->allowedActions = 
     array('index','view','archive','listarchive','viewfromcategory','tags','aboutme','contact','polls'); 

的AppController:

class AppController extends Controller { 
    var $components = array('Acl', 'Session', 'Auth','RequestHandler'); 
    //var $helpers = array('Html', 'Form','Js','Session','Cache'); 
    var $helpers = array('Html', 'Form','Js','Session'); 

    function beforeFilter() { 
     //Configure AuthComponent   
     $this->Auth->actionPath = 'controllers/'; 

     $this->Auth->allowedActions = array('display'); 

     //$this->Auth->authorize = 'actions'; 
     $this->Auth->loginAction = array('controller' => 'users', 'action' => 'login'); 
     $this->Auth->logoutRedirect = array('controller' => 'posts', 'action' => 'index'); 
     $this->Auth->loginRedirect = array('controller' => 'posts', 'action' => 'index'); 
    } 

哪有我修復這個公關oblem?

回答

3

Cake 2.0 migration guide提到:

AuthComponent

的AuthComponent完全是重新分解爲2.0,這樣做是爲了幫助 減少開發者的困惑和無奈。另外, AuthComponent變得更加靈活和可擴展。您可以在Authentication指南中找到更多 。

由於cakephp核心發生變化,您將收到該錯誤消息,因此應根據新指南調整代碼。

修改控制器內部的數據陣列時,我也遇到了同樣的問題:

$this->data['foo'] = 'bar'; 

,不得不關掉這個使用新CakeRequest對象:

$this->request->data['foo'] = 'bar'; 
1

要解決警告你可以請按照下列步驟操作:

在您的「PostsController」中替換爲:

$this->Auth->allowedActions = 
    array('index','view','archive','listarchive','viewfromcategory','tags','aboutme','contact','polls'); 

通過

$this->Auth->allow(array('index','view','archive','listarchive','viewfromcategory','tags','aboutme','contact','polls'));