2011-10-20 71 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'));