2012-07-22 160 views
2

CakePHP 2 book/Acl Tutorial/Part 2,我执行命令:AclExtras警告错误

./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表获取与NULL填充在modelNULL在所有foreign_key的字段。

我该如何解决这个错误?

enter image description here

感谢

在AclExtras /控制台/命令

回答

9

,请更改开机功能:

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

穆斯塔法可能有正确的答案,因为它出现这个代码变化使它成为CakePHP的本身。请参阅GitHub:https://github.com/markstory/acl_extras/issues/16 – 2012-08-04 18:49:08