Skip to content

Commit ea4c162

Browse files
nickvergessenjuliusknorr
authored andcommitted
Adjust notifier to Nextcloud 17
Signed-off-by: Joas Schilling <coding@schilljs.com>
1 parent ea4f4e8 commit ea4c162

File tree

2 files changed

+22
-7
lines changed

2 files changed

+22
-7
lines changed

lib/AppInfo/Application.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -141,12 +141,7 @@ public function registerNavigationEntry() {
141141

142142
public function registerNotifications() {
143143
$notificationManager = \OC::$server->getNotificationManager();
144-
$self = &$this;
145-
$notificationManager->registerNotifier(function() use (&$self) {
146-
return $self->getContainer()->query(Notifier::class);
147-
}, function() {
148-
return ['id' => 'deck', 'name' => 'Deck'];
149-
});
144+
$notificationManager->registerNotifierService(Notifier::class);
150145
}
151146

152147
/**

lib/Notification/Notifier.php

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,34 @@ public function __construct(
5757
$this->boardMapper = $boardMapper;
5858
}
5959

60+
/**
61+
* Identifier of the notifier, only use [a-z0-9_]
62+
*
63+
* @return string
64+
* @since 17.0.0
65+
*/
66+
public function getID(): string {
67+
return 'deck';
68+
}
69+
70+
/**
71+
* Human readable name describing the notifier
72+
*
73+
* @return string
74+
* @since 17.0.0
75+
*/
76+
public function getName(): string {
77+
return $this->l10nFactory->get('deck')->t('Deck');
78+
}
79+
6080
/**
6181
* @param INotification $notification
6282
* @param string $languageCode The code of the language that should be used to prepare the notification
6383
* @return INotification
6484
* @throws \InvalidArgumentException When the notification was not prepared by a notifier
6585
* @since 9.0.0
6686
*/
67-
public function prepare(INotification $notification, $languageCode) {
87+
public function prepare(INotification $notification, string $languageCode): INotification {
6888
$l = $this->l10nFactory->get('deck', $languageCode);
6989
if ($notification->getApp() !== 'deck') {
7090
throw new \InvalidArgumentException();

0 commit comments

Comments
 (0)