public static function listenEvent($event, $callback, $priority = 50, $important = false)
    {
        if (!isset(self::$events[$event])) {
            self::$events[$event] = array();
        }
        
        // while there is an event with the same priority, checks
        // with an higher or lower priority
        while (isset(self::$events[$event][$priority])) {
            $priority += $important ? -1 : 1;
        }
        
        self::$events[$event][$priority] = $callback;
    }
public static function listenEvent($event, $callback, $priority = 50, $important = false)
    {
        if (!isset(self::$events[$event])) {
            self::$events[$event] = array();
        }
        
        // while there is an event with the same priority, checks
        // with an higher or lower priority
        while (isset(self::$events[$event][$priority])) {
            $priority += $important ? -1 : 1;
        }
        
        self::$events[$event][$priority] = $callback;
    }
public static function listenEvent ( $ event , $ callback , $ priority = 50 , $ important = false ) { if ( ! isset ( self :: $ events [ $ event ] ) ) { self :: $ events [ $ event ] = array ( ) ; } // while there is an event with the same priority, checks // with an higher or lower priority while ( isset ( self :: $ events [ $ event ] [ $ priority ] ) ) { $ priority += $ important ? - 1 : 1 ; } self :: $ events [ $ event ] [ $ priority ] = $ callback ; }
Registers a callback to an event

@param string $event Event name
@param callback $callback The callback to call when the event is fired
@param int $priority Listener priority
@param bool $important If true and a listener of the same priority already exists, registers the new listener before the existing one.
Registers a callback to an event