aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph Wurst <ChristophWurst@users.noreply.github.com>2020-02-27 13:08:42 +0100
committerGitHub <noreply@github.com>2020-02-27 13:08:42 +0100
commitf83589f75d8a99011fe536b8e1685010ec6df7fd (patch)
tree5e8f21254730d8fb4ca79205a096603f57f90c2a
parent72cc8270cdd0f1c95ef1708be81cf4ac424dca47 (diff)
parent3ffed429256a1634d0103188ddb5e211616cc355 (diff)
downloadnextcloud-server-f83589f75d8a99011fe536b8e1685010ec6df7fd.tar.gz
nextcloud-server-f83589f75d8a99011fe536b8e1685010ec6df7fd.zip
Merge pull request #19670 from nextcloud/techdebt/noid/allow-to-remove-listeners
Allow to remove listeners
-rw-r--r--lib/private/EventDispatcher/EventDispatcher.php5
-rw-r--r--lib/public/EventDispatcher/IEventDispatcher.php8
2 files changed, 13 insertions, 0 deletions
diff --git a/lib/private/EventDispatcher/EventDispatcher.php b/lib/private/EventDispatcher/EventDispatcher.php
index 9baa8fc9516..4f83d15bffd 100644
--- a/lib/private/EventDispatcher/EventDispatcher.php
+++ b/lib/private/EventDispatcher/EventDispatcher.php
@@ -63,6 +63,11 @@ class EventDispatcher implements IEventDispatcher {
$this->dispatcher->addListener($eventName, $listener, $priority);
}
+ public function removeListener(string $eventName,
+ callable $listener): void {
+ $this->dispatcher->removeListener($eventName, $listener);
+ }
+
public function addServiceListener(string $eventName,
string $className,
int $priority = 0): void {
diff --git a/lib/public/EventDispatcher/IEventDispatcher.php b/lib/public/EventDispatcher/IEventDispatcher.php
index e8b63e6f03c..e6e1bc5ce61 100644
--- a/lib/public/EventDispatcher/IEventDispatcher.php
+++ b/lib/public/EventDispatcher/IEventDispatcher.php
@@ -43,6 +43,14 @@ interface IEventDispatcher {
public function addListener(string $eventName, callable $listener, int $priority = 0): void;
/**
+ * @param string $eventName preferably the fully-qualified class name of the Event sub class
+ * @param callable $listener the object that is invoked when a matching event is dispatched
+ *
+ * @since 19.0.0
+ */
+ public function removeListener(string $eventName, callable $listener): void;
+
+ /**
* @param string $eventName preferably the fully-qualified class name of the Event sub class to listen for
* @param string $className fully qualified class name (or ::class notation) of a \OCP\EventDispatcher\IEventListener that can be built by the DI container
* @param int $priority