如何创建 ACO?
我想我已经理解了 CakePHP
中几乎所有内容的基础,直到 访问控制列表
,现在我在 11.2.5 创建 ACO(访问控制对象),我不明白必须将 AclComponent
方法:
$this->Acl->Aco->create(array('parent_id' => null, 'alias' => 'controllers'));
$this->Acl->Aco->save();
我应该在哪个文件中插入此代码?
我需要在某些特定的语句中插入吗?
我不明白这一行到底是做什么的,所以我无法找到它应该在何时何地运行,这段代码的作用是什么,以及何时应该工作?
I think I have undestood the bases of almost everything in CakePHP
until the Access Control Lists
, now I'm on 11.2.5 Creating ACOs (Access Control Objects) and I don't understand where I have to put the AclComponent
methods:
$this->Acl->Aco->create(array('parent_id' => null, 'alias' => 'controllers'));
$this->Acl->Aco->save();
In which file I should insert this code?
Have I to inserti in some specific statement?
I don't undestand what this line does exactly, so I can't locate where and when it should run, what this code does, and when It should work?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
ACO 记录创建的想法是,如果您的项目结束(意味着没有创建新操作),您不需要再在 acos 数据表中插入任何内容。这些方法旨在被调用一次或仅调用几次。
然后由您决定将这些代码行放置在哪里,因为无论如何您之后可能会删除它们。
或者,要填充 acos 数据表,您也可以使用此插件 http://www.alaxos .net/blaxos/pages/view/plugin_acl 自动检测新操作并建议相应地完成 acos 数据表。
The idea with the ACO records creation is that if your project is over (meaning no new actions are created), you don't need to insert anything anymore in the acos datatable. These methods are intended to be called once, or only a few times.
It is then up to you to decide where you want to place these lines of code, as anyway you will probably remove them afterwards.
Alternatively, to fill the acos datatable, you could also use this plugin http://www.alaxos.net/blaxos/pages/view/plugin_acl that automatically detects new actions and propose to complete the acos datatable accordingly.
您可以将其插入到需要创建 Aco-s 的任何位置。在 app_controller 或任何控制器中。
you can insert that wherever you need to create Aco-s. in app_controller, or in any controller.
Cookbook 中的此页面为您提供了一个非常好的自动化工具来创建 ACO:
http://book.cakephp.org/view/647/An-Automated-tool-for-creating-ACOs
如果将 build_acl 函数添加到 AppController,则可以从任何控制器运行它,并且它会为您生成 ACO。它在我使用 ACL 的应用程序中始终运行良好。
This page in the Cookbook gives you a very nice automated tool for creating ACOs:
http://book.cakephp.org/view/647/An-Automated-tool-for-creating-ACOs
If you add the build_acl function to the AppController, you can run it from any controller and it generates your ACOs for you. It's always worked very nicely in my ACL-using applications.