Skip to content

Commit

Permalink
[EventDispatcher] made order deterministic (first registered one stay…
Browse files Browse the repository at this point in the history
… first) -- this makes the new system more compatible with the old one
  • Loading branch information
fabpot committed Mar 18, 2011
1 parent 1c6715f commit 25ff09f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion EventDispatcher.php
Expand Up @@ -192,7 +192,10 @@ private function sortListeners($eventName)
$p = $this->priorities[$eventName];

uasort($this->listeners[$eventName], function ($a, $b) use ($p) {
return $p[spl_object_hash($b)] - $p[spl_object_hash($a)];
$order = $p[spl_object_hash($b)] - $p[spl_object_hash($a)];

// for the same priority, force the first registered one to stay first
return 0 === $order ? 1 : $order;
});

$this->sorted[$eventName] = true;
Expand Down

0 comments on commit 25ff09f

Please sign in to comment.