diff options
author | Roeland Jago Douma <rullzer@users.noreply.github.com> | 2019-08-15 11:14:29 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-15 11:14:29 +0300 |
commit | 3fd7eaf151996b9e334c96e8c3476cbdc3c10440 (patch) | |
tree | 2751d8d305bcb275fc7df1583839e04d057f5e2b | |
parent | 783b01dfcfac153c5bc79a4379795e83ef599ada (diff) | |
parent | 3ebe0103d0408fec6a716d97652940dcd6cf1352 (diff) |
Merge pull request #40 from nextcloud/bugfix/noid/notification-adjustmentsv17.0.0beta1
Adjust notifier to Nextcloud 17
-rw-r--r-- | lib/AppInfo/Application.php | 10 | ||||
-rw-r--r-- | lib/Notification/Notifier.php | 22 |
2 files changed, 22 insertions, 10 deletions
diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index 12bce4a..990a42c 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -39,14 +39,6 @@ class Application extends App { } protected function registerNotificationNotifier() { - $this->getContainer()->getServer()->getNotificationManager()->registerNotifier(function() { - return $this->getContainer()->query(Notifier::class); - }, function() { - $l = $this->getContainer()->getServer()->getL10NFactory()->get(self::APP_ID); - return [ - 'id' => self::APP_ID, - 'name' => $l->t('Nextcloud announcements'), - ]; - }); + $this->getContainer()->getServer()->getNotificationManager()->registerNotifierService(Notifier::class); } } diff --git a/lib/Notification/Notifier.php b/lib/Notification/Notifier.php index 4391836..835b85a 100644 --- a/lib/Notification/Notifier.php +++ b/lib/Notification/Notifier.php @@ -54,12 +54,32 @@ class Notifier implements INotifier { } /** + * Identifier of the notifier, only use [a-z0-9_] + * + * @return string + * @since 17.0.0 + */ + public function getID(): string { + return $this->appName; + } + + /** + * Human readable name describing the notifier + * + * @return string + * @since 17.0.0 + */ + public function getName(): string { + return $this->l10nFactory->get($this->appName)->t('Nextcloud announcements'); + } + + /** * @param INotification $notification * @param string $languageCode The code of the language that should be used to prepare the notification * @return INotification * @throws \InvalidArgumentException When the notification was not prepared by a notifier */ - public function prepare(INotification $notification, $languageCode) { + public function prepare(INotification $notification, string $languageCode): INotification { if ($notification->getApp() !== $this->appName) { // Not my app => throw throw new \InvalidArgumentException(); |