From bfe39f2f53f016e55dc1d7f7c0a941f70c64184b Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Mon, 26 Feb 2024 17:00:10 +0100 Subject: [PATCH] fix: Replace deprecated code Signed-off-by: Ferdinand Thiessen --- lib/AppInfo/Application.php | 11 ++++++----- lib/Listener/AppEnabledListener.php | 14 +++++++------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index 2a418a0cd..4cb3fb871 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -4,7 +4,7 @@ * * @author Joas Schilling * - * @license GNU AGPL version 3 or any later version + * @license AGPL-3.0-or-later * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as @@ -26,7 +26,7 @@ use OCA\FirstRunWizard\Listener\AppEnabledListener; use OCA\FirstRunWizard\Listener\BeforeTemplateRenderedListener; use OCA\FirstRunWizard\Notification\Notifier; -use OCP\App\ManagerEvent; +use OCP\App\Events\AppEnableEvent; use OCP\AppFramework\App; use OCP\AppFramework\Bootstrap\IBootContext; use OCP\AppFramework\Bootstrap\IBootstrap; @@ -41,12 +41,13 @@ public function __construct() { } public function register(IRegistrationContext $context): void { - $context->registerEventListener(ManagerEvent::EVENT_APP_ENABLE, AppEnabledListener::class); + $context->registerNotifierService(Notifier::class); + + $context->registerEventListener(AppEnableEvent::class, AppEnabledListener::class); $context->registerEventListener(BeforeTemplateRenderedEvent::class, BeforeTemplateRenderedListener::class); } public function boot(IBootContext $context): void { - $serverContainer = $context->getServerContainer(); - $serverContainer->getNotificationManager()->registerNotifierService(Notifier::class); + // Everything is already done in register() } } diff --git a/lib/Listener/AppEnabledListener.php b/lib/Listener/AppEnabledListener.php index a4ca125fa..b6cfab6be 100644 --- a/lib/Listener/AppEnabledListener.php +++ b/lib/Listener/AppEnabledListener.php @@ -7,7 +7,7 @@ * * @author Morris Jobke * - * @license GNU AGPL version 3 or any later version + * @license AGPL-3.0-or-later * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as @@ -27,20 +27,20 @@ namespace OCA\FirstRunWizard\Listener; use OCA\FirstRunWizard\Notification\AppHint; -use OCP\App\ManagerEvent; +use OCP\App\Events\AppEnableEvent; use OCP\EventDispatcher\Event; use OCP\EventDispatcher\IEventListener; +/** @template-implements IEventListener */ class AppEnabledListener implements IEventListener { - /** @var AppHint */ - private $appHint; - public function __construct(AppHint $appHint) { - $this->appHint = $appHint; + public function __construct( + private AppHint $appHint, + ) { } public function handle(Event $event): void { - if (!$event instanceof ManagerEvent) { + if (!$event instanceof AppEnableEvent) { return; }