array('Acl' => array('type' => 'requester')) 和 array('Acl' =) 之间的区别> CakePHP 中的“请求者”?
我正在关注 CakePHP 1.3 的 ACL 教程,我想知道声明这样的行为之间是否存在功能差异:
var $actsAs = array('Acl' => 'requester');
和这样:
var $actsAs = array('Acl' => array('type' => 'requester'));
I'm following the ACL tutorial for CakePHP 1.3 and I was wondering if there is a functional difference between declaring a behavior like this:
var $actsAs = array('Acl' => 'requester');
and like this:
var $actsAs = array('Acl' => array('type' => 'requester'));
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尽管您的两个示例对于 CakePHP 1.3.4 来说都是有效且正确的(
cake/libs/model/behaviors/acl.php
lines 48-51),bancer 发布的建议的第三种方法不正确。由于 AclBehavior 在找不到配置时默认为“请求者”,因此这是一个潜在的令人沮丧的错误,因为它会按预期工作,直到您尝试将类型更改为“受控”。 (它在 CakePHP 1.2 中也不起作用 - Mark Story 制作对该行的更改 匿名用户的建议。)如果您确实想替换第三个示例,则var $actsAs = array('Acl');
应该没问题(除非您希望类型
被'控制'
,但您可以看到添加该选项)。Though your two examples are both valid and correct for CakePHP 1.3.4 (
cake/libs/model/behaviors/acl.php
lines 48-51), the suggested third method posted by bancer is not correct. Because the AclBehavior defaults to 'requester' when it cannot find the configuration, this is a potentially frustrating bug in that it will work as expected until you attempt to change the type to 'controlled'. (it also doesn't work in CakePHP 1.2 - Mark Story made a change to that line at the advice of an anonymous user.) If you do want to replace your third example,var $actsAs = array('Acl');
should do fine (unless you wanttype
to be'controlled'
, but you can then see to add the option).没有什么区别。您甚至可以声明 这样:
There is no difference. You can even declare this way: