From 6d71e471e166c30c0b9abe05d36240b9f1556d8e Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 30 Apr 2019 14:29:30 +0200 Subject: Update shipped implementations of the INotifier Signed-off-by: Joas Schilling --- apps/user_ldap/appinfo/app.php | 12 +----------- apps/user_ldap/lib/Notification/Notifier.php | 22 +++++++++++++++++++++- 2 files changed, 22 insertions(+), 12 deletions(-) (limited to 'apps/user_ldap') diff --git a/apps/user_ldap/appinfo/app.php b/apps/user_ldap/appinfo/app.php index 5afd928301a..34b850e655d 100644 --- a/apps/user_ldap/appinfo/app.php +++ b/apps/user_ldap/appinfo/app.php @@ -42,17 +42,7 @@ if(count($configPrefixes) > 0) { $ldapWrapper = new OCA\User_LDAP\LDAP(); $ocConfig = \OC::$server->getConfig(); $notificationManager = \OC::$server->getNotificationManager(); - $notificationManager->registerNotifier(function() { - return new \OCA\User_LDAP\Notification\Notifier( - \OC::$server->getL10NFactory() - ); - }, function() { - $l = \OC::$server->getL10N('user_ldap'); - return [ - 'id' => 'user_ldap', - 'name' => $l->t('LDAP user and group backend'), - ]; - }); + $notificationManager->registerNotifier(\OCA\User_LDAP\Notification\Notifier::class); $userSession = \OC::$server->getUserSession(); $userPluginManager = \OC::$server->query('LDAPUserPluginManager'); diff --git a/apps/user_ldap/lib/Notification/Notifier.php b/apps/user_ldap/lib/Notification/Notifier.php index 34625a3bef4..2c89743fa72 100644 --- a/apps/user_ldap/lib/Notification/Notifier.php +++ b/apps/user_ldap/lib/Notification/Notifier.php @@ -42,13 +42,33 @@ class Notifier implements INotifier { $this->l10nFactory = $l10nFactory; } + /** + * Identifier of the notifier, only use [a-z0-9_] + * + * @return string + * @since 17.0.0 + */ + public function getID(): string { + return 'user_ldap'; + } + + /** + * Human readable name describing the notifier + * + * @return string + * @since 17.0.0 + */ + public function getName(): string { + return $this->l10nFactory->get('user_ldap')->t('LDAP User backend'); + } + /** * @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() !== 'user_ldap') { // Not my app => throw throw new \InvalidArgumentException(); -- cgit v1.2.3