2

CakePHP 2 book / Acl Tutorial / Part 2中,我正在执行命令:

./Console/cake AclExtras.AclExtras aco_sync

我收到一个警告错误:

Warning Error: Argument 1 passed to Component::startup() must be an instance of Controller, 
null given, called in 
/opt/lampp/htdocs/acl/app/Plugin/AclExtras/Console/Command/AclExtrasShell.php 
on line 80 and defined in [/opt/lampp/htdocs/acl/lib/Cake/Controller/Component.php, line 119]

acos 表填充了NULLinmodel字段NULLforeign_key.

我该如何解决这个错误?

在此处输入图像描述

谢谢

4

1 回答 1

9

在 AclExtras/Console/Command 中,请将启动功能更改为:

public function startup() {
    parent::startup();
    $controller = new Controller();
    $collection = new ComponentCollection();
    $this->Acl = new AclComponent($collection);
    $this->Acl->startup($controller);
    $this->Aco = $this->Acl->Aco;
}
于 2012-08-01T23:11:44.153 回答