aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files/lib
diff options
context:
space:
mode:
authorJoas Schilling <213943+nickvergessen@users.noreply.github.com>2023-08-04 10:39:57 +0200
committerGitHub <noreply@github.com>2023-08-04 10:39:57 +0200
commit44b4c16a091592203df51c19d0be1b520bc3ad9b (patch)
tree25ee31ab54832dc2bc984f4f91940c30dcb8ac33 /apps/files/lib
parentf8bd676154f988ef2130ccb0e29b0cc95e42a204 (diff)
parent3962cd0aa8ab7530deffa3b41cab2e11a01fd14a (diff)
downloadnextcloud-server-44b4c16a091592203df51c19d0be1b520bc3ad9b.tar.gz
nextcloud-server-44b4c16a091592203df51c19d0be1b520bc3ad9b.zip
Merge pull request #39605 from nextcloud/bugfix/noid/final-events-cleanup
fix!: Final round of moving to IEventDispatcher
Diffstat (limited to 'apps/files/lib')
-rw-r--r--apps/files/lib/AppInfo/Application.php5
-rw-r--r--apps/files/lib/Collaboration/Resources/Listener.php9
-rw-r--r--apps/files/lib/Listener/LegacyLoadAdditionalScriptsAdapter.php57
-rw-r--r--apps/files/lib/Service/TagService.php21
4 files changed, 19 insertions, 73 deletions
diff --git a/apps/files/lib/AppInfo/Application.php b/apps/files/lib/AppInfo/Application.php
index 3cbe8d9d950..feba7b09178 100644
--- a/apps/files/lib/AppInfo/Application.php
+++ b/apps/files/lib/AppInfo/Application.php
@@ -42,7 +42,6 @@ use OCA\Files\Controller\ApiController;
use OCA\Files\DirectEditingCapabilities;
use OCA\Files\Event\LoadAdditionalScriptsEvent;
use OCA\Files\Event\LoadSidebar;
-use OCA\Files\Listener\LegacyLoadAdditionalScriptsAdapter;
use OCA\Files\Listener\LoadSidebarListener;
use OCA\Files\Listener\RenderReferenceEventListener;
use OCA\Files\Notification\Notifier;
@@ -57,6 +56,7 @@ use OCP\AppFramework\Bootstrap\IBootstrap;
use OCP\AppFramework\Bootstrap\IRegistrationContext;
use OCP\Collaboration\Reference\RenderReferenceEvent;
use OCP\Collaboration\Resources\IProviderManager;
+use OCP\EventDispatcher\IEventDispatcher;
use OCP\IConfig;
use OCP\IL10N;
use OCP\IPreview;
@@ -110,7 +110,7 @@ class Application extends App implements IBootstrap {
$c->get(IActivityManager::class),
$c->get(ITagManager::class)->load(self::APP_ID),
$server->getUserFolder(),
- $server->getEventDispatcher()
+ $c->get(IEventDispatcher::class),
);
});
@@ -120,7 +120,6 @@ class Application extends App implements IBootstrap {
$context->registerCapability(Capabilities::class);
$context->registerCapability(DirectEditingCapabilities::class);
- $context->registerEventListener(LoadAdditionalScriptsEvent::class, LegacyLoadAdditionalScriptsAdapter::class);
$context->registerEventListener(LoadSidebar::class, LoadSidebarListener::class);
$context->registerEventListener(RenderReferenceEvent::class, RenderReferenceEventListener::class);
diff --git a/apps/files/lib/Collaboration/Resources/Listener.php b/apps/files/lib/Collaboration/Resources/Listener.php
index 28ce5f87897..e37bf0e9610 100644
--- a/apps/files/lib/Collaboration/Resources/Listener.php
+++ b/apps/files/lib/Collaboration/Resources/Listener.php
@@ -28,12 +28,15 @@ namespace OCA\Files\Collaboration\Resources;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Server;
use OCP\Collaboration\Resources\IManager;
+use OCP\Share\Events\ShareCreatedEvent;
+use OCP\Share\Events\ShareDeletedEvent;
+use OCP\Share\Events\ShareDeletedFromSelfEvent;
class Listener {
public static function register(IEventDispatcher $dispatcher): void {
- $dispatcher->addListener('OCP\Share::postShare', [self::class, 'shareModification']);
- $dispatcher->addListener('OCP\Share::postUnshare', [self::class, 'shareModification']);
- $dispatcher->addListener('OCP\Share::postUnshareFromSelf', [self::class, 'shareModification']);
+ $dispatcher->addListener(ShareCreatedEvent::class, [self::class, 'shareModification']);
+ $dispatcher->addListener(ShareDeletedEvent::class, [self::class, 'shareModification']);
+ $dispatcher->addListener(ShareDeletedFromSelfEvent::class, [self::class, 'shareModification']);
}
public static function shareModification(): void {
diff --git a/apps/files/lib/Listener/LegacyLoadAdditionalScriptsAdapter.php b/apps/files/lib/Listener/LegacyLoadAdditionalScriptsAdapter.php
deleted file mode 100644
index f60f9d73d78..00000000000
--- a/apps/files/lib/Listener/LegacyLoadAdditionalScriptsAdapter.php
+++ /dev/null
@@ -1,57 +0,0 @@
-<?php
-
-declare(strict_types=1);
-
-/**
- * @copyright Copyright (c) 2019, Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @author Joas Schilling <coding@schilljs.com>
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-namespace OCA\Files\Listener;
-
-use OC\EventDispatcher\SymfonyAdapter;
-use OCA\Files\Event\LoadAdditionalScriptsEvent;
-use OCP\EventDispatcher\Event;
-use OCP\EventDispatcher\IEventListener;
-use Symfony\Component\EventDispatcher\GenericEvent;
-
-class LegacyLoadAdditionalScriptsAdapter implements IEventListener {
-
- /** @var SymfonyAdapter */
- private $dispatcher;
-
- public function __construct(SymfonyAdapter $dispatcher) {
- $this->dispatcher = $dispatcher;
- }
-
- public function handle(Event $event): void {
- if (!($event instanceof LoadAdditionalScriptsEvent)) {
- return;
- }
-
- $legacyEvent = new GenericEvent(null, ['hiddenFields' => []]);
- $this->dispatcher->dispatch('OCA\Files::loadAdditionalScripts', $legacyEvent);
-
- $hiddenFields = $legacyEvent->getArgument('hiddenFields');
- foreach ($hiddenFields as $name => $value) {
- $event->addHiddenField($name, $value);
- }
- }
-}
diff --git a/apps/files/lib/Service/TagService.php b/apps/files/lib/Service/TagService.php
index af4f7d0ef1e..e29848bf21d 100644
--- a/apps/files/lib/Service/TagService.php
+++ b/apps/files/lib/Service/TagService.php
@@ -26,12 +26,13 @@ namespace OCA\Files\Service;
use OCA\Files\Activity\FavoriteProvider;
use OCP\Activity\IManager;
+use OCP\EventDispatcher\IEventDispatcher;
+use OCP\Files\Events\NodeAddedToFavorite;
+use OCP\Files\Events\NodeRemovedFromFavorite;
use OCP\Files\Folder;
use OCP\ITags;
use OCP\IUser;
use OCP\IUserSession;
-use Symfony\Component\EventDispatcher\EventDispatcherInterface;
-use Symfony\Component\EventDispatcher\GenericEvent;
/**
* Service class to manage tags on files.
@@ -46,7 +47,7 @@ class TagService {
private $tagger;
/** @var Folder|null */
private $homeFolder;
- /** @var EventDispatcherInterface */
+ /** @var IEventDispatcher */
private $dispatcher;
public function __construct(
@@ -54,7 +55,7 @@ class TagService {
IManager $activityManager,
?ITags $tagger,
?Folder $homeFolder,
- EventDispatcherInterface $dispatcher
+ IEventDispatcher $dispatcher,
) {
$this->userSession = $userSession;
$this->activityManager = $activityManager;
@@ -120,12 +121,12 @@ class TagService {
return;
}
- $eventName = $addToFavorite ? 'addFavorite' : 'removeFavorite';
- $this->dispatcher->dispatch(self::class . '::' . $eventName, new GenericEvent(null, [
- 'userId' => $user->getUID(),
- 'fileId' => $fileId,
- 'path' => $path,
- ]));
+ if ($addToFavorite) {
+ $event = new NodeAddedToFavorite($user, $fileId, $path);
+ } else {
+ $event = new NodeRemovedFromFavorite($user, $fileId, $path);
+ }
+ $this->dispatcher->dispatchTyped($event);
$event = $this->activityManager->generateEvent();
try {