Difference between array('Acl' => array('type' => 'requester')) and array('Acl' => 'requester') in CakePHP?
I'm following the ACL tutorial 开发者_JS百科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'));
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 want type
to be 'controlled'
, but you can then see to add the option).
There is no difference. You can even declare this way:
var $actsAs = array('Acl' => array('requester'));
精彩评论