diff options
author | Christoph Wurst <christoph@winzerhof-wurst.at> | 2019-09-16 18:09:43 +0200 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2019-10-28 13:58:13 +0100 |
commit | d180a987149df30dacceb85b07d0bfbf9adc265e (patch) | |
tree | cba51fa719b50044bb8b370ba313df6c097bce40 /lib/private/EventDispatcher/EventDispatcher.php | |
parent | 908f13e9b961cafafe349d4906a6a8357d65b20f (diff) | |
download | nextcloud-server-d180a987149df30dacceb85b07d0bfbf9adc265e.tar.gz nextcloud-server-d180a987149df30dacceb85b07d0bfbf9adc265e.zip |
Make it possible to broadcast events to (web) clients
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'lib/private/EventDispatcher/EventDispatcher.php')
-rw-r--r-- | lib/private/EventDispatcher/EventDispatcher.php | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/private/EventDispatcher/EventDispatcher.php b/lib/private/EventDispatcher/EventDispatcher.php index 8830bae79d8..d9d7985f7cc 100644 --- a/lib/private/EventDispatcher/EventDispatcher.php +++ b/lib/private/EventDispatcher/EventDispatcher.php @@ -25,7 +25,10 @@ declare(strict_types=1); namespace OC\EventDispatcher; +use OC\Broadcast\Events\BroadcastEvent; +use OCP\Broadcast\Events\IBroadcastEvent; use OCP\EventDispatcher\Event; +use OCP\EventDispatcher\ABroadcastedEvent; use OCP\EventDispatcher\IEventDispatcher; use OCP\IContainer; use OCP\ILogger; @@ -73,6 +76,14 @@ class EventDispatcher implements IEventDispatcher { public function dispatch(string $eventName, Event $event): void { $this->dispatcher->dispatch($event, $eventName); + + if ($event instanceof ABroadcastedEvent && !$event->isPropagationStopped()) { + // Propagate broadcast + $this->dispatch( + IBroadcastEvent::class, + new BroadcastEvent($event) + ); + } } public function dispatchTyped(Event $event): void { |