如何在CakePHP 2.X中使用initialize

时间:2012-12-14 11:21:48

标签: cakephp

我正在将Cake 1.3应用程序迁移到2.X应用程序。它主要运行良好,但我不明白如何为Cake 2重写此代码。

    public function initialize(&$controller) {
        $this->Controller =& $controller;
    }

错误警告是: 无法通过引用分配重载对象

1 个答案:

答案 0 :(得分:2)

你真的应该阅读迁移指南 http://book.cakephp.org/2.0/en/appendices/2-0-migration-guide.html

public function initialize(Controller $controller) {
    $this->Controller = $controller;
}

您可以尝试运行我的升级shell。它应该解决大部分问题: https://github.com/dereuromark/upgrade

cake Upgrade.Correct reference

应该做的伎俩

请参阅https://github.com/dereuromark/upgrade/blob/master/Console/Command/CorrectShell.php#L733