diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index 0f6dc03e..093118fc 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -9,6 +9,7 @@ use Exception; use OC\Files\Filesystem; +use OCA\DAV\Events\SabrePluginAddEvent; use OCA\Registration\Events\PassedFormEvent; use OCA\Registration\Events\ShowFormEvent; use OCA\Registration\Events\ValidateFormEvent; @@ -30,7 +31,6 @@ use OCP\IUser; use OCP\IUserSession; use OCP\Notification\IManager; -use OCP\SabrePluginEvent; use OCP\User\Events\UserDeletedEvent; use OCP\User\Events\UserFirstTimeLoggedInEvent; use OCP\Util; @@ -61,16 +61,14 @@ public function boot(IBootContext $context): void { Util::connectHook('OC_Filesystem', 'preSetup', $this, 'addStorageWrapper'); $eventDispatcher = $context->getServerContainer()->get(IEventDispatcher::class); - $eventDispatcher->addListener('OCA\DAV\Connector\Sabre::addPlugin', function (SabrePluginEvent $event) use ($context): void { + $eventDispatcher->addListener(SabrePluginAddEvent::class, function (SabrePluginAddEvent $event) use ($context): void { $eventServer = $event->getServer(); - if ($eventServer !== null) { - // We have to register the CheckPlugin here and not info.xml, - // because info.xml plugins are loaded, after the - // beforeMethod:* hook has already been emitted. - $plugin = $context->getAppContainer()->get(CheckPlugin::class); - $eventServer->addPlugin($plugin); - } + // We have to register the CheckPlugin here and not info.xml, + // because info.xml plugins are loaded, after the + // beforeMethod:* hook has already been emitted. + $plugin = $context->getAppContainer()->get(CheckPlugin::class); + $eventServer->addPlugin($plugin); }); $context->injectFn($this->registerNotifier(...)); diff --git a/psalm.xml b/psalm.xml index 9d0e2b0b..c4126f84 100644 --- a/psalm.xml +++ b/psalm.xml @@ -50,5 +50,6 @@ + diff --git a/tests/stubs/filesystem.php b/tests/stubs/filesystem.php index bea9d24a..5a102a81 100644 --- a/tests/stubs/filesystem.php +++ b/tests/stubs/filesystem.php @@ -181,7 +181,10 @@ public function getInstanceOfStorage(string $class): ?IStorage { public function __call($method, $args) { } - public function getDirectDownload($path): array|false { + public function getDirectDownload(string $path): array|false { + } + + public function getDirectDownloadById(string $fileId): array|false { } public function getAvailability(): array { diff --git a/tests/stubs/oca_dav_events_sabrepluginaddevent.php b/tests/stubs/oca_dav_events_sabrepluginaddevent.php new file mode 100644 index 00000000..4192a72b --- /dev/null +++ b/tests/stubs/oca_dav_events_sabrepluginaddevent.php @@ -0,0 +1,35 @@ +