From f064fe55e2f40b17f4fea3b5a5873da912d2b8de Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 16 Jul 2019 12:02:40 +0200 Subject: [PATCH] Adjust notifier to Nextcloud 17 Signed-off-by: Joas Schilling --- lib/AppInfo/Application.php | 7 +------ lib/Notification/Notifier.php | 22 +++++++++++++++++++++- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index 5463e26ed..7348242f7 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -141,12 +141,7 @@ class Application extends App { public function registerNotifications() { $notificationManager = \OC::$server->getNotificationManager(); - $self = &$this; - $notificationManager->registerNotifier(function() use (&$self) { - return $self->getContainer()->query(Notifier::class); - }, function() { - return ['id' => 'deck', 'name' => 'Deck']; - }); + $notificationManager->registerNotifierService(Notifier::class); } /** diff --git a/lib/Notification/Notifier.php b/lib/Notification/Notifier.php index 2b47e375a..2c5d27b48 100644 --- a/lib/Notification/Notifier.php +++ b/lib/Notification/Notifier.php @@ -57,6 +57,26 @@ class Notifier implements INotifier { $this->boardMapper = $boardMapper; } + /** + * Identifier of the notifier, only use [a-z0-9_] + * + * @return string + * @since 17.0.0 + */ + public function getID(): string { + return 'deck'; + } + + /** + * Human readable name describing the notifier + * + * @return string + * @since 17.0.0 + */ + public function getName(): string { + return $this->l10nFactory->get('deck')->t('Deck'); + } + /** * @param INotification $notification * @param string $languageCode The code of the language that should be used to prepare the notification @@ -64,7 +84,7 @@ class Notifier implements INotifier { * @throws \InvalidArgumentException When the notification was not prepared by a notifier * @since 9.0.0 */ - public function prepare(INotification $notification, $languageCode) { + public function prepare(INotification $notification, string $languageCode): INotification { $l = $this->l10nFactory->get('deck', $languageCode); if ($notification->getApp() !== 'deck') { throw new \InvalidArgumentException();