2012-07-22 186 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