Check event against listeners registered in local and global manager

Closes #2730
This commit is contained in:
Rachman Chavik 2014-01-31 16:50:14 +07:00
parent 35c22a291e
commit 9f978e9bf7

View file

@ -259,16 +259,18 @@ class CakeEventManager {
* @return array
*/
public function listeners($eventKey) {
$globalListeners = array();
if (!$this->_isGlobal) {
$globalListeners = self::instance()->prioritisedListeners($eventKey);
} else {
$globalListeners = $this->prioritisedListeners($eventKey);
}
$listeners = array_merge($this->_listeners, self::instance()->_listeners);
if (empty($this->_listeners[$eventKey]) && empty($globalListeners)) {
if (empty($listeners[$eventKey]) && empty($globalListeners)) {
return array();
}
$listeners = $this->_listeners[$eventKey];
$listeners = $listeners[$eventKey];
foreach ($globalListeners as $priority => $priorityQ) {
if (!empty($listeners[$priority])) {
$listeners[$priority] = array_merge($priorityQ, $listeners[$priority]);