Skip to content
Permalink
Browse files

Dropping short syntax support for Behavior configuration.

Also making sure that $settings comming from ObjectCollection::normalizeObjectArray() is always an array.
  • Loading branch information...
renan committed Oct 15, 2011
1 parent d2a664c commit 3a04bb473371f4f27a861257ba0f9a24ca399968
@@ -41,7 +41,7 @@ class AclNode extends AppModel {
*
* @var array
*/
public $actsAs = array('Tree' => array('nested'));
public $actsAs = array('Tree' => array('type' => 'nested'));
/**
* Constructor
@@ -36,16 +36,13 @@ class AclBehavior extends ModelBehavior {
protected $_typeMaps = array('requester' => 'Aro', 'controlled' => 'Aco', 'both' => array('Aro', 'Aco'));
/**
* Sets up the configuation for the model, and loads ACL models if they haven't been already
* Sets up the configuration for the model, and loads ACL models if they haven't been already
*
* @param Model $model
* @param array $config
* @return void
*/
public function setup($model, $config = array()) {
if (is_string($config)) {
$config = array('type' => $config);
}
$this->settings[$model->name] = array_merge(array('type' => 'controlled'), (array)$config);
$this->settings[$model->name]['type'] = strtolower($this->settings[$model->name]['type']);
@@ -64,9 +64,6 @@ public function setup($Model, $settings = array()) {
if (!isset($this->settings[$Model->alias])) {
$this->settings[$Model->alias] = array('recursive' => true, 'notices' => true, 'autoFields' => true);
}
if (!is_array($settings)) {
$settings = array();
}
$this->settings[$Model->alias] = array_merge($this->settings[$Model->alias], $settings);
}
@@ -55,9 +55,6 @@ class TreeBehavior extends ModelBehavior {
* @return void
*/
public function setup($Model, $config = array()) {
if (!is_array($config)) {
$config = array('type' => $config);
}
$settings = array_merge($this->_defaults, $config);
if (in_array($settings['scope'], $Model->getAssociated('belongsTo'))) {
@@ -53,7 +53,7 @@ class AclPerson extends CakeTestModel {
*
* @var array
*/
public $actsAs = array('Acl' => 'both');
public $actsAs = array('Acl' => array('type' => 'both'));
/**
* belongsTo property
@@ -128,7 +128,7 @@ class AclUser extends CakeTestModel {
*
* @var array
*/
public $actsAs = array('Acl' => 'requester');
public $actsAs = array('Acl' => array('type' => 'requester'));
/**
* parentNode
@@ -166,7 +166,7 @@ class AclPost extends CakeTestModel {
*
* @var array
*/
public $actsAs = array('Acl' => 'Controlled');
public $actsAs = array('Acl' => array('type' => 'Controlled'));
/**
* parentNode
@@ -402,6 +402,16 @@ public function testnormalizeObjectArray() {
'Apple' => array('class' => 'Banana.Apple', 'settings' => array('foo' => 'bar')),
);
$this->assertEquals($expected, $result);
// This is the result after Controller::_mergeVars
$components = array(
'Html' => null,
'Foo.Bar' => array('one', 'two'),
'Something' => null,
'Banana.Apple' => array('foo' => 'bar')
);
$result = ObjectCollection::normalizeObjectArray($components);
$this->assertEquals($expected, $result);
}
}
@@ -247,7 +247,8 @@ public static function normalizeObjectArray($objects) {
foreach ($objects as $i => $objectName) {
$options = array();
if (!is_int($i)) {
list($options, $objectName) = array($objectName, $i);
$options = (array)$objectName;
$objectName = $i;
}
list($plugin, $name) = pluginSplit($objectName);
$normal[$name] = array('class' => $objectName, 'settings' => $options);

0 comments on commit 3a04bb4

Please sign in to comment.
You can’t perform that action at this time.