mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
fix issues #2897
This commit is contained in:
parent
0f584c0e8b
commit
9d4f3e92ab
1 changed files with 16 additions and 19 deletions
|
@ -259,30 +259,27 @@ class CakeEventManager {
|
|||
* @return array
|
||||
*/
|
||||
public function listeners($eventKey) {
|
||||
$localListeners = array();
|
||||
$priorities = array();
|
||||
if (!$this->_isGlobal) {
|
||||
$localListeners = $this->prioritisedListeners($eventKey);
|
||||
$localListeners = empty($localListeners) ? array() : $localListeners;
|
||||
}
|
||||
$globalListeners = self::instance()->prioritisedListeners($eventKey);
|
||||
} else {
|
||||
$globalListeners = $this->prioritisedListeners($eventKey);
|
||||
}
|
||||
$listeners = array_merge($this->_listeners, self::instance()->_listeners);
|
||||
$globalListeners = empty($globalListeners) ? array() : $globalListeners;
|
||||
|
||||
if (empty($listeners[$eventKey]) && empty($globalListeners)) {
|
||||
return array();
|
||||
}
|
||||
$priorities = array_merge(array_keys($globalListeners), array_keys($localListeners));
|
||||
$priorities = array_unique($priorities);
|
||||
asort($priorities);
|
||||
|
||||
$listeners = $listeners[$eventKey];
|
||||
foreach ($globalListeners as $priority => $priorityQ) {
|
||||
if (!empty($listeners[$priority])) {
|
||||
$listeners[$priority] = array_merge($priorityQ, $listeners[$priority]);
|
||||
unset($globalListeners[$priority]);
|
||||
}
|
||||
}
|
||||
$listeners = $listeners + $globalListeners;
|
||||
|
||||
ksort($listeners);
|
||||
$result = array();
|
||||
foreach ($listeners as $priorityQ) {
|
||||
$result = array_merge($result, $priorityQ);
|
||||
foreach ($priorities as $priority) {
|
||||
if (isset($globalListeners[$priority])) {
|
||||
$result = array_merge($result, $globalListeners[$priority]);
|
||||
}
|
||||
if (isset($localListeners[$priority])) {
|
||||
$result = array_merge($result, $localListeners[$priority]);
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue