Added override and clear methods to event class.
Signed-off-by: Taylor Otwell <taylorotwell@gmail.com>
This commit is contained in:
parent
2331ae18cf
commit
fdcebc1bcb
|
@ -40,6 +40,31 @@ public static function listen($event, $callback)
|
||||||
static::$events[$event][] = $callback;
|
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.
|
* Fire an event and return the first response.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue