|
@@ -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.
|
|
|
*
|