diff options
author | Joas Schilling <213943+nickvergessen@users.noreply.github.com> | 2023-08-04 10:39:57 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-04 10:39:57 +0200 |
commit | 44b4c16a091592203df51c19d0be1b520bc3ad9b (patch) | |
tree | 25ee31ab54832dc2bc984f4f91940c30dcb8ac33 /apps | |
parent | f8bd676154f988ef2130ccb0e29b0cc95e42a204 (diff) | |
parent | 3962cd0aa8ab7530deffa3b41cab2e11a01fd14a (diff) | |
download | nextcloud-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')
17 files changed, 40 insertions, 169 deletions
diff --git a/apps/dav/lib/AppInfo/Application.php b/apps/dav/lib/AppInfo/Application.php index 4ed68e68840..9b185963dcc 100644 --- a/apps/dav/lib/AppInfo/Application.php +++ b/apps/dav/lib/AppInfo/Application.php @@ -69,6 +69,7 @@ use OCA\DAV\Events\CardDeletedEvent; use OCA\DAV\Events\CardUpdatedEvent; use OCA\DAV\Events\SubscriptionCreatedEvent; use OCA\DAV\Events\SubscriptionDeletedEvent; +use OCP\Accounts\UserUpdatedEvent; use OCP\EventDispatcher\IEventDispatcher; use OCP\Federation\Events\TrustedServerRemovedEvent; use OCA\DAV\HookManager; @@ -224,13 +225,10 @@ class Application extends App implements IBootstrap { } }); - $dispatcher->addListener('OC\AccountManager::userUpdated', function ($event) use ($container) { - if ($event instanceof GenericEvent) { - $user = $event->getSubject(); - /** @var SyncService $syncService */ - $syncService = $container->query(SyncService::class); - $syncService->updateUser($user); - } + $dispatcher->addListener(UserUpdatedEvent::class, function (UserUpdatedEvent $event) use ($container) { + /** @var SyncService $syncService */ + $syncService = \OCP\Server::get(SyncService::class); + $syncService->updateUser($event->getUser()); }); diff --git a/apps/files/composer/composer/autoload_classmap.php b/apps/files/composer/composer/autoload_classmap.php index c6d03ffd3be..0f3e01b5b53 100644 --- a/apps/files/composer/composer/autoload_classmap.php +++ b/apps/files/composer/composer/autoload_classmap.php @@ -57,7 +57,6 @@ return array( 'OCA\\Files\\Event\\LoadSidebar' => $baseDir . '/../lib/Event/LoadSidebar.php', 'OCA\\Files\\Exception\\TransferOwnershipException' => $baseDir . '/../lib/Exception/TransferOwnershipException.php', 'OCA\\Files\\Helper' => $baseDir . '/../lib/Helper.php', - 'OCA\\Files\\Listener\\LegacyLoadAdditionalScriptsAdapter' => $baseDir . '/../lib/Listener/LegacyLoadAdditionalScriptsAdapter.php', 'OCA\\Files\\Listener\\LoadSidebarListener' => $baseDir . '/../lib/Listener/LoadSidebarListener.php', 'OCA\\Files\\Listener\\RenderReferenceEventListener' => $baseDir . '/../lib/Listener/RenderReferenceEventListener.php', 'OCA\\Files\\Migration\\Version11301Date20191205150729' => $baseDir . '/../lib/Migration/Version11301Date20191205150729.php', diff --git a/apps/files/composer/composer/autoload_static.php b/apps/files/composer/composer/autoload_static.php index 2cb71917bd6..2b152c734f1 100644 --- a/apps/files/composer/composer/autoload_static.php +++ b/apps/files/composer/composer/autoload_static.php @@ -72,7 +72,6 @@ class ComposerStaticInitFiles 'OCA\\Files\\Event\\LoadSidebar' => __DIR__ . '/..' . '/../lib/Event/LoadSidebar.php', 'OCA\\Files\\Exception\\TransferOwnershipException' => __DIR__ . '/..' . '/../lib/Exception/TransferOwnershipException.php', 'OCA\\Files\\Helper' => __DIR__ . '/..' . '/../lib/Helper.php', - 'OCA\\Files\\Listener\\LegacyLoadAdditionalScriptsAdapter' => __DIR__ . '/..' . '/../lib/Listener/LegacyLoadAdditionalScriptsAdapter.php', 'OCA\\Files\\Listener\\LoadSidebarListener' => __DIR__ . '/..' . '/../lib/Listener/LoadSidebarListener.php', 'OCA\\Files\\Listener\\RenderReferenceEventListener' => __DIR__ . '/..' . '/../lib/Listener/RenderReferenceEventListener.php', 'OCA\\Files\\Migration\\Version11301Date20191205150729' => __DIR__ . '/..' . '/../lib/Migration/Version11301Date20191205150729.php', 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 { diff --git a/apps/files/tests/Service/TagServiceTest.php b/apps/files/tests/Service/TagServiceTest.php index dce01e7170f..2b9bc5be460 100644 --- a/apps/files/tests/Service/TagServiceTest.php +++ b/apps/files/tests/Service/TagServiceTest.php @@ -29,10 +29,10 @@ namespace OCA\Files\Tests\Service; use OCA\Files\Service\TagService; use OCP\Activity\IManager; +use OCP\EventDispatcher\IEventDispatcher; use OCP\ITags; use OCP\IUser; use OCP\IUserSession; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; /** * Class TagServiceTest @@ -59,7 +59,7 @@ class TagServiceTest extends \Test\TestCase { */ private $root; - /** @var EventDispatcherInterface|\PHPUnit\Framework\MockObject\MockObject */ + /** @var IEventDispatcher|\PHPUnit\Framework\MockObject\MockObject */ private $dispatcher; /** @@ -90,7 +90,7 @@ class TagServiceTest extends \Test\TestCase { ->willReturn($user); $this->root = \OC::$server->getUserFolder(); - $this->dispatcher = $this->createMock(EventDispatcherInterface::class); + $this->dispatcher = $this->createMock(IEventDispatcher::class); $this->tagger = \OC::$server->getTagManager()->load('files'); $this->tagService = $this->getTagService(['addActivity']); diff --git a/apps/files_external/lib/Service/BackendService.php b/apps/files_external/lib/Service/BackendService.php index 2cfc1d48b2e..056b288a88b 100644 --- a/apps/files_external/lib/Service/BackendService.php +++ b/apps/files_external/lib/Service/BackendService.php @@ -33,6 +33,7 @@ use OCA\Files_External\Lib\Backend\Backend; use OCA\Files_External\Lib\Config\IAuthMechanismProvider; use OCA\Files_External\Lib\Config\IBackendProvider; use OCP\EventDispatcher\GenericEvent; +use OCP\EventDispatcher\IEventDispatcher; use OCP\IConfig; /** @@ -112,7 +113,7 @@ class BackendService { private function callForRegistrations() { static $eventSent = false; if (!$eventSent) { - \OC::$server->getEventDispatcher()->dispatch( + \OC::$server->get(IEventDispatcher::class)->dispatch( 'OCA\\Files_External::loadAdditionalBackends', new GenericEvent() ); diff --git a/apps/files_sharing/composer/composer/autoload_classmap.php b/apps/files_sharing/composer/composer/autoload_classmap.php index 394fd7f5410..e3dc35addba 100644 --- a/apps/files_sharing/composer/composer/autoload_classmap.php +++ b/apps/files_sharing/composer/composer/autoload_classmap.php @@ -55,7 +55,6 @@ return array( 'OCA\\Files_Sharing\\Helper' => $baseDir . '/../lib/Helper.php', 'OCA\\Files_Sharing\\Hooks' => $baseDir . '/../lib/Hooks.php', 'OCA\\Files_Sharing\\ISharedStorage' => $baseDir . '/../lib/ISharedStorage.php', - 'OCA\\Files_Sharing\\Listener\\LegacyBeforeTemplateRenderedListener' => $baseDir . '/../lib/Listener/LegacyBeforeTemplateRenderedListener.php', 'OCA\\Files_Sharing\\Listener\\LoadAdditionalListener' => $baseDir . '/../lib/Listener/LoadAdditionalListener.php', 'OCA\\Files_Sharing\\Listener\\LoadSidebarListener' => $baseDir . '/../lib/Listener/LoadSidebarListener.php', 'OCA\\Files_Sharing\\Listener\\ShareInteractionListener' => $baseDir . '/../lib/Listener/ShareInteractionListener.php', diff --git a/apps/files_sharing/composer/composer/autoload_static.php b/apps/files_sharing/composer/composer/autoload_static.php index 652ea9281ff..56a98d1b718 100644 --- a/apps/files_sharing/composer/composer/autoload_static.php +++ b/apps/files_sharing/composer/composer/autoload_static.php @@ -70,7 +70,6 @@ class ComposerStaticInitFiles_Sharing 'OCA\\Files_Sharing\\Helper' => __DIR__ . '/..' . '/../lib/Helper.php', 'OCA\\Files_Sharing\\Hooks' => __DIR__ . '/..' . '/../lib/Hooks.php', 'OCA\\Files_Sharing\\ISharedStorage' => __DIR__ . '/..' . '/../lib/ISharedStorage.php', - 'OCA\\Files_Sharing\\Listener\\LegacyBeforeTemplateRenderedListener' => __DIR__ . '/..' . '/../lib/Listener/LegacyBeforeTemplateRenderedListener.php', 'OCA\\Files_Sharing\\Listener\\LoadAdditionalListener' => __DIR__ . '/..' . '/../lib/Listener/LoadAdditionalListener.php', 'OCA\\Files_Sharing\\Listener\\LoadSidebarListener' => __DIR__ . '/..' . '/../lib/Listener/LoadSidebarListener.php', 'OCA\\Files_Sharing\\Listener\\ShareInteractionListener' => __DIR__ . '/..' . '/../lib/Listener/ShareInteractionListener.php', diff --git a/apps/files_sharing/lib/AppInfo/Application.php b/apps/files_sharing/lib/AppInfo/Application.php index 65197e9b270..d89419b8ea9 100644 --- a/apps/files_sharing/lib/AppInfo/Application.php +++ b/apps/files_sharing/lib/AppInfo/Application.php @@ -37,7 +37,6 @@ use OCA\Files_Sharing\Event\BeforeTemplateRenderedEvent; use OCA\Files_Sharing\External\Manager; use OCA\Files_Sharing\External\MountProvider as ExternalMountProvider; use OCA\Files_Sharing\Helper; -use OCA\Files_Sharing\Listener\LegacyBeforeTemplateRenderedListener; use OCA\Files_Sharing\Listener\LoadAdditionalListener; use OCA\Files_Sharing\Listener\LoadSidebarListener; use OCA\Files_Sharing\Listener\ShareInteractionListener; @@ -133,7 +132,6 @@ class Application extends App implements IBootstrap { public function registerEventsScripts(IEventDispatcher $dispatcher): void { // sidebar and files scripts $dispatcher->addServiceListener(LoadAdditionalScriptsEvent::class, LoadAdditionalListener::class); - $dispatcher->addServiceListener(BeforeTemplateRenderedEvent::class, LegacyBeforeTemplateRenderedListener::class); $dispatcher->addServiceListener(LoadSidebar::class, LoadSidebarListener::class); $dispatcher->addServiceListener(ShareCreatedEvent::class, ShareInteractionListener::class); $dispatcher->addServiceListener(ShareCreatedEvent::class, UserShareAcceptanceListener::class); @@ -143,10 +141,7 @@ class Application extends App implements IBootstrap { }); // notifications api to accept incoming user shares - $dispatcher->addListener('OCP\Share::postShare', function ($event) { - if (!$event instanceof OldGenericEvent) { - return; - } + $dispatcher->addListener(ShareCreatedEvent::class, function (ShareCreatedEvent $event) { /** @var Listener $listener */ $listener = $this->getContainer()->query(Listener::class); $listener->shareNotification($event); diff --git a/apps/files_sharing/lib/Listener/LegacyBeforeTemplateRenderedListener.php b/apps/files_sharing/lib/Listener/LegacyBeforeTemplateRenderedListener.php deleted file mode 100644 index e7e81c3a17a..00000000000 --- a/apps/files_sharing/lib/Listener/LegacyBeforeTemplateRenderedListener.php +++ /dev/null @@ -1,57 +0,0 @@ -<?php - -declare(strict_types=1); - -/** - * @copyright Copyright (c) 2019, Roeland Jago Douma <roeland@famdouma.nl> - * - * @author Julius Härtl <jus@bitgrid.net> - * - * @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_Sharing\Listener; - -use OC\EventDispatcher\SymfonyAdapter; -use OCA\Files_Sharing\Event\BeforeTemplateRenderedEvent; -use OCP\EventDispatcher\Event; -use OCP\EventDispatcher\IEventListener; -use Symfony\Component\EventDispatcher\GenericEvent; - -class LegacyBeforeTemplateRenderedListener implements IEventListener { - - /** @var SymfonyAdapter */ - private $dispatcher; - - public function __construct(SymfonyAdapter $dispatcher) { - $this->dispatcher = $dispatcher; - } - - public function handle(Event $event): void { - if (!($event instanceof BeforeTemplateRenderedEvent)) { - return; - } - - $eventName = 'OCA\Files_Sharing::loadAdditionalScripts'; - - if ($event->getScope() !== null) { - $eventName .= '::' . $event->getScope(); - } - - $legacyEvent = new GenericEvent(null, ['share' => $event->getShare()]); - $this->dispatcher->dispatch($eventName, $legacyEvent); - } -} diff --git a/apps/files_sharing/lib/Notification/Listener.php b/apps/files_sharing/lib/Notification/Listener.php index db7939767d6..b6d30cdb3f5 100644 --- a/apps/files_sharing/lib/Notification/Listener.php +++ b/apps/files_sharing/lib/Notification/Listener.php @@ -31,6 +31,7 @@ use OCP\IGroupManager; use OCP\IUser; use OCP\Notification\IManager as INotificationManager; use OCP\Notification\INotification; +use OCP\Share\Events\ShareCreatedEvent; use OCP\Share\IManager as IShareManager; use OCP\Share\IShare; use Symfony\Component\EventDispatcher\GenericEvent; @@ -54,12 +55,8 @@ class Listener { $this->groupManager = $groupManager; } - /** - * @param GenericEvent $event - */ - public function shareNotification(GenericEvent $event): void { - /** @var IShare $share */ - $share = $event->getSubject(); + public function shareNotification(ShareCreatedEvent $event): void { + $share = $event->getShare(); $notification = $this->instantiateNotification($share); if ($share->getShareType() === IShare::TYPE_USER) { diff --git a/apps/files_sharing/tests/CapabilitiesTest.php b/apps/files_sharing/tests/CapabilitiesTest.php index fcefc556203..0d21718f98a 100644 --- a/apps/files_sharing/tests/CapabilitiesTest.php +++ b/apps/files_sharing/tests/CapabilitiesTest.php @@ -46,7 +46,6 @@ use OCP\Security\IHasher; use OCP\Security\ISecureRandom; use OCP\Share\IProviderFactory; use Psr\Log\LoggerInterface; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; /** * Class CapabilitiesTest @@ -90,7 +89,6 @@ class CapabilitiesTest extends \Test\TestCase { $this->createMock(IProviderFactory::class), $this->createMock(IUserManager::class), $this->createMock(IRootFolder::class), - $this->createMock(EventDispatcherInterface::class), $this->createMock(IMailer::class), $this->createMock(IURLGenerator::class), $this->createMock(\OC_Defaults::class), diff --git a/apps/lookup_server_connector/lib/AppInfo/Application.php b/apps/lookup_server_connector/lib/AppInfo/Application.php index 8d6700c0eaa..fbcf54f83de 100644 --- a/apps/lookup_server_connector/lib/AppInfo/Application.php +++ b/apps/lookup_server_connector/lib/AppInfo/Application.php @@ -30,6 +30,7 @@ namespace OCA\LookupServerConnector\AppInfo; use Closure; use OCA\LookupServerConnector\UpdateLookupServer; +use OCP\Accounts\UserUpdatedEvent; use OCP\AppFramework\App; use OCP\AppFramework\Bootstrap\IBootContext; use OCP\AppFramework\Bootstrap\IBootstrap; @@ -58,15 +59,10 @@ class Application extends App implements IBootstrap { */ private function registerEventListeners(IEventDispatcher $dispatcher, ContainerInterface $appContainer): void { - $dispatcher->addListener('OC\AccountManager::userUpdated', function ($event) use ($appContainer) { - if ($event instanceof GenericEvent) { - /** @var IUser $user */ - $user = $event->getSubject(); - - /** @var UpdateLookupServer $updateLookupServer */ - $updateLookupServer = $appContainer->get(UpdateLookupServer::class); - $updateLookupServer->userUpdated($user); - } + $dispatcher->addListener(UserUpdatedEvent::class, function (UserUpdatedEvent $event) use ($appContainer) { + /** @var UpdateLookupServer $updateLookupServer */ + $updateLookupServer = $appContainer->get(UpdateLookupServer::class); + $updateLookupServer->userUpdated($event->getUser()); }); } } diff --git a/apps/systemtags/lib/AppInfo/Application.php b/apps/systemtags/lib/AppInfo/Application.php index a0aac7486d1..8d82931296c 100644 --- a/apps/systemtags/lib/AppInfo/Application.php +++ b/apps/systemtags/lib/AppInfo/Application.php @@ -25,6 +25,7 @@ declare(strict_types=1); */ namespace OCA\SystemTags\AppInfo; +use OCA\Files\Event\LoadAdditionalScriptsEvent; use OCA\SystemTags\Search\TagSearchProvider; use OCA\SystemTags\Activity\Listener; use OCP\AppFramework\App; @@ -52,7 +53,7 @@ class Application extends App implements IBootstrap { * @todo move the OCP events and then move the registration to `register` */ $dispatcher->addListener( - 'OCA\Files::loadAdditionalScripts', + LoadAdditionalScriptsEvent::class, function () { \OCP\Util::addScript('core', 'systemtags'); \OCP\Util::addScript(self::APP_ID, 'systemtags'); |