mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
simplify the code for object collection
Fixed up some abreviated variables, removing extra long lines and removed variables that were not used.
This commit is contained in:
parent
b227ff486e
commit
91c09d87bc
1 changed files with 16 additions and 15 deletions
|
@ -126,6 +126,7 @@ abstract class ObjectCollection {
|
||||||
if ($options['modParams'] !== false && !isset($params[$options['modParams']])) {
|
if ($options['modParams'] !== false && !isset($params[$options['modParams']])) {
|
||||||
throw new CakeException(__d('cake_dev', 'Cannot use modParams with indexes that do not exist.'));
|
throw new CakeException(__d('cake_dev', 'Cannot use modParams with indexes that do not exist.'));
|
||||||
}
|
}
|
||||||
|
$result = null;
|
||||||
foreach ($list as $name) {
|
foreach ($list as $name) {
|
||||||
$result = call_user_func_array(array($this->_loaded[$name], $callback), compact('subject') + $params);
|
$result = call_user_func_array(array($this->_loaded[$name], $callback), compact('subject') + $params);
|
||||||
if ($options['collectReturn'] === true) {
|
if ($options['collectReturn'] === true) {
|
||||||
|
@ -180,7 +181,10 @@ abstract class ObjectCollection {
|
||||||
$enabled = false;
|
$enabled = false;
|
||||||
foreach ((array)$name as $object) {
|
foreach ((array)$name as $object) {
|
||||||
if (isset($this->_loaded[$object]) && !isset($this->_enabled[$object])) {
|
if (isset($this->_loaded[$object]) && !isset($this->_enabled[$object])) {
|
||||||
$priority = isset($this->_loaded[$object]->settings['priority']) ? $this->_loaded[$object]->settings['priority'] : $this->defaultPriority;
|
$priority = $this->defaultPriority;
|
||||||
|
if (isset($this->_loaded[$object]->settings['priority'])) {
|
||||||
|
$priority = $this->_loaded[$object]->settings['priority'];
|
||||||
|
}
|
||||||
$this->_enabled[$object] = array($priority);
|
$this->_enabled[$object] = array($priority);
|
||||||
$enabled = true;
|
$enabled = true;
|
||||||
}
|
}
|
||||||
|
@ -218,14 +222,14 @@ abstract class ObjectCollection {
|
||||||
if (is_string($name)) {
|
if (is_string($name)) {
|
||||||
$name = array($name => $priority);
|
$name = array($name => $priority);
|
||||||
}
|
}
|
||||||
foreach ($name as $obj => $prio) {
|
foreach ($name as $object => $objectPriority) {
|
||||||
if (isset($this->_loaded[$obj])) {
|
if (isset($this->_loaded[$object])) {
|
||||||
if (is_null($prio)) {
|
if (is_null($objectPriority)) {
|
||||||
$prio = $this->defaultPriority;
|
$objectPriority = $this->defaultPriority;
|
||||||
}
|
}
|
||||||
$this->_loaded[$obj]->settings['priority'] = $prio;
|
$this->_loaded[$object]->settings['priority'] = $objectPriority;
|
||||||
if (isset($this->_enabled[$obj])) {
|
if (isset($this->_enabled[$object])) {
|
||||||
$this->_enabled[$obj] = array($prio);
|
$this->_enabled[$object] = array($objectPriority);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -282,9 +286,8 @@ abstract class ObjectCollection {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function unload($name) {
|
public function unload($name) {
|
||||||
list($plugin, $name) = pluginSplit($name);
|
$name = array_pop(pluginSplit($name));
|
||||||
unset($this->_loaded[$name]);
|
unset($this->_loaded[$name], $this->_enabled[$name]);
|
||||||
unset($this->_enabled[$name]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -296,8 +299,7 @@ abstract class ObjectCollection {
|
||||||
*/
|
*/
|
||||||
public function set($name = null, $object = null) {
|
public function set($name = null, $object = null) {
|
||||||
if (!empty($name) && !empty($object)) {
|
if (!empty($name) && !empty($object)) {
|
||||||
list($plugin, $name) = pluginSplit($name);
|
$this->_loaded[array_pop(pluginSplit($name))] = $object;
|
||||||
$this->_loaded[$name] = $object;
|
|
||||||
}
|
}
|
||||||
return $this->_loaded;
|
return $this->_loaded;
|
||||||
}
|
}
|
||||||
|
@ -317,8 +319,7 @@ abstract class ObjectCollection {
|
||||||
$options = (array)$objectName;
|
$options = (array)$objectName;
|
||||||
$objectName = $i;
|
$objectName = $i;
|
||||||
}
|
}
|
||||||
list($plugin, $name) = pluginSplit($objectName);
|
$normal[array_pop(pluginSplit($objectName))] = array('class' => $objectName, 'settings' => $options);
|
||||||
$normal[$name] = array('class' => $objectName, 'settings' => $options);
|
|
||||||
}
|
}
|
||||||
return $normal;
|
return $normal;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue