使用Cake的aco_sync进行ACO节点复制

时间:2014-11-05 06:52:16

标签: cakephp

我(为了简单起见)3个控制器:

AppController
    - action
    - anotherAction

PostsContoller
    - index
    - add

UsersController
    - index
    - add
    - edit

如果我运行./lib/Cake/Console/cake AclExtras.AclExtras aco_sync,我会收到以下信息:

Created Aco node: controllers/PostsController
Created Aco node: controllers/PostsController/index
Created Aco node: controllers/PostsController/add
Created Aco node: controllers/PostsController/action
Created Aco node: controllers/PostsController/anotherAction
Created Aco node: controllers/UsersController
Created Aco node: controllers/UsersController/index
Created Aco node: controllers/UsersController/add
Created Aco node: controllers/UsersController/edit
Created Aco node: controllers/UsersController/action
Created Aco node: controllers/UsersController/anotherAction

换句话说,我的AppController中的两个动作是通过aco_sync为每个其他控制器拾取一次

这是正常的,还是指向某处的配置错误?

1 个答案:

答案 0 :(得分:1)

这很正常。如果将控制器定义为class PostsController extends AppControllerclass UsersControllers extends AppController,则这两个类继承AppController的方法(注意:只有公共方法和受保护方法,而不是私有方法)。

您也可以从PostsController和UsersController调用$this->action()$this->anotherAction()

这是继承的工作原理。