From c2ae699215ad6e0a8bb92e6d6ffc09c6c88e4f9a Mon Sep 17 00:00:00 2001 From: Carl Schwan Date: Thu, 18 Dec 2025 11:30:44 +0100 Subject: [PATCH] refactor: Use modern SabrePluginAddEvent Signed-off-by: Carl Schwan --- lib/AppInfo/Application.php | 8 ++--- psalm.xml | 3 ++ .../oca_dav_events_sabrepluginaddevent.php | 35 +++++++++++++++++++ 3 files changed, 42 insertions(+), 4 deletions(-) create mode 100644 tests/stubs/oca_dav_events_sabrepluginaddevent.php diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index 6be6d092..8782c2ca 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -24,6 +24,7 @@ use OCA\AppAPI\Notifications\ExAppNotifier; use OCA\AppAPI\PublicCapabilities; use OCA\AppAPI\SetupChecks\DaemonCheck; +use OCA\DAV\Events\SabrePluginAddEvent; use OCA\DAV\Events\SabrePluginAuthInitEvent; use OCA\Files\Event\LoadAdditionalScriptsEvent; use OCP\AppFramework\App; @@ -32,7 +33,6 @@ use OCP\AppFramework\Bootstrap\IRegistrationContext; use OCP\EventDispatcher\IEventDispatcher; use OCP\Navigation\Events\LoadAdditionalEntriesEvent; -use OCP\SabrePluginEvent; use OCP\Settings\Events\DeclarativeSettingsGetValueEvent; use OCP\Settings\Events\DeclarativeSettingsRegisterFormEvent; use OCP\Settings\Events\DeclarativeSettingsSetValueEvent; @@ -77,9 +77,9 @@ public function boot(IBootContext $context): void { public function registerDavAuth(): void { $container = $this->getContainer(); - $dispatcher = $container->query(IEventDispatcher::class); - $dispatcher->addListener('OCA\DAV\Connector\Sabre::addPlugin', function (SabrePluginEvent $event) use ($container) { - $event->getServer()->addPlugin($container->query(DavPlugin::class)); + $dispatcher = $container->get(IEventDispatcher::class); + $dispatcher->addListener(SabrePluginAddEvent::class, function (SabrePluginAddEvent $event) use ($container) { + $event->getServer()->addPlugin($container->get(DavPlugin::class)); }); } } diff --git a/psalm.xml b/psalm.xml index 4d087f3d..751a678c 100644 --- a/psalm.xml +++ b/psalm.xml @@ -54,4 +54,7 @@ + + + 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 @@ +