/** * This function determines the correct order that events should be executed in. * Events are executed based off priority, with `Event::kHIGH` priority executing * first. If there is more than one Event of the same priority, they are then * executed in alphabetical order. This function is designed to be used with * PHP's uasort function. * * @link http://php.net/manual/en/function.uasort.php * @param Event $a * @param Event $b * @return integer */ private function __findEventOrder($a, $b) { if ($a->priority() == $b->priority()) { $a = $a->about(); $b = $b->about(); $handles = array($a['name'], $b['name']); asort($handles); return key($handles) == 0 ? -1 : 1; } return $a->priority() > $b->priority() ? -1 : 1; }