Adjust notifier to Nextcloud 17
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
committed by
Julius Härtl
parent
799497e62f
commit
f064fe55e2
@@ -141,12 +141,7 @@ class Application extends App {
|
|||||||
|
|
||||||
public function registerNotifications() {
|
public function registerNotifications() {
|
||||||
$notificationManager = \OC::$server->getNotificationManager();
|
$notificationManager = \OC::$server->getNotificationManager();
|
||||||
$self = &$this;
|
$notificationManager->registerNotifierService(Notifier::class);
|
||||||
$notificationManager->registerNotifier(function() use (&$self) {
|
|
||||||
return $self->getContainer()->query(Notifier::class);
|
|
||||||
}, function() {
|
|
||||||
return ['id' => 'deck', 'name' => 'Deck'];
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -57,6 +57,26 @@ class Notifier implements INotifier {
|
|||||||
$this->boardMapper = $boardMapper;
|
$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 INotification $notification
|
||||||
* @param string $languageCode The code of the language that should be used to prepare the 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
|
* @throws \InvalidArgumentException When the notification was not prepared by a notifier
|
||||||
* @since 9.0.0
|
* @since 9.0.0
|
||||||
*/
|
*/
|
||||||
public function prepare(INotification $notification, $languageCode) {
|
public function prepare(INotification $notification, string $languageCode): INotification {
|
||||||
$l = $this->l10nFactory->get('deck', $languageCode);
|
$l = $this->l10nFactory->get('deck', $languageCode);
|
||||||
if ($notification->getApp() !== 'deck') {
|
if ($notification->getApp() !== 'deck') {
|
||||||
throw new \InvalidArgumentException();
|
throw new \InvalidArgumentException();
|
||||||
|
|||||||
Reference in New Issue
Block a user