]> source.dussan.org Git - nextcloud-server.git/commitdiff
Allow to remove listeners 19670/head
authorJoas Schilling <coding@schilljs.com>
Thu, 27 Feb 2020 10:01:29 +0000 (11:01 +0100)
committerJoas Schilling <coding@schilljs.com>
Thu, 27 Feb 2020 10:04:23 +0000 (11:04 +0100)
Signed-off-by: Joas Schilling <coding@schilljs.com>
lib/private/EventDispatcher/EventDispatcher.php
lib/public/EventDispatcher/IEventDispatcher.php

index 9baa8fc95163698623f869501189c04be46727f3..4f83d15bffd04e29b5bdc90ecc16430ac86be795 100644 (file)
@@ -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 {
index e8b63e6f03c1b0e7d7d958a1d77ef975e4735f8e..e6e1bc5ce61c386c2584d712a9db79501b5b0450 100644 (file)
@@ -42,6 +42,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