mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
Dropping short syntax support for Behavior configuration.
Also making sure that $settings comming from ObjectCollection::normalizeObjectArray() is always an array.
This commit is contained in:
parent
d2a664c2df
commit
3a04bb4733
7 changed files with 17 additions and 15 deletions
|
@ -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 @@ class ContainableBehavior extends ModelBehavior {
|
|||
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 @@ class ObjectCollectionTest extends CakeTestCase {
|
|||
'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 @@ abstract class ObjectCollection {
|
|||
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);
|
||||
|
|
Loading…
Add table
Reference in a new issue