Commit fdcebc1b authored by Taylor Otwell's avatar Taylor Otwell

Added override and clear methods to event class.

Signed-off-by: 's avatarTaylor Otwell <taylorotwell@gmail.com>
parent 2331ae18
......@@ -40,6 +40,31 @@ class Event {
static::$events[$event][] = $callback;
}
/**
* Override all callbacks for a given event with a new callback.
*
* @param string $event
* @param mixed $callback
* @return void
*/
public static function override($event, $callback)
{
static::clear($event);
static::listen($event, $callback);
}
/**
* Clear all event listeners for a given event.
*
* @param string $event
* @return void
*/
public static function clear($event)
{
static::$events[$event] = array();
}
/**
* Fire an event and return the first response.
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment