]> source.dussan.org Git - nextcloud-server.git/commitdiff
Update twofactor_backupcodes Notifier
authorJoas Schilling <coding@schilljs.com>
Fri, 12 Apr 2019 11:44:23 +0000 (13:44 +0200)
committerJoas Schilling <coding@schilljs.com>
Mon, 15 Jul 2019 13:12:43 +0000 (15:12 +0200)
Signed-off-by: Joas Schilling <coding@schilljs.com>
apps/twofactor_backupcodes/lib/AppInfo/Application.php
apps/twofactor_backupcodes/lib/Notifications/Notifier.php

index 041af03706785942e9f76c7150128350df89bcd7..c4e02aaa26141c91e0039d567490f075028473c9 100644 (file)
@@ -74,15 +74,7 @@ class Application extends App {
                $container = $this->getContainer();
                /** @var IManager $manager */
                $manager = $container->query(IManager::class);
-               $manager->registerNotifier(
-                       function() use ($container) {
-                               return $container->query(Notifier::class);
-                       },
-                       function () use ($container) {
-                               $l = $container->query(IL10N::class);
-                               return ['id' => 'twofactor_backupcodes', 'name' => $l->t('Second-factor backup codes')];
-                       }
-               );
+               $manager->registerNotifier(Notifier::class);
        }
 
        public function deleteUser($params) {
index df92c7a9e014e30371f85dc3f4b2d29953520c83..5e53a32df77403b19f8c0192e899fdd79832bc1b 100644 (file)
@@ -42,7 +42,27 @@ class Notifier implements INotifier {
                $this->url = $url;
        }
 
-       public function prepare(INotification $notification, $languageCode) {
+       /**
+        * Identifier of the notifier, only use [a-z0-9_]
+        *
+        * @return string
+        * @since 17.0.0
+        */
+       public function getID(): string {
+               return 'twofactor_backupcodes';
+       }
+
+       /**
+        * Human readable name describing the notifier
+        *
+        * @return string
+        * @since 17.0.0
+        */
+       public function getName(): string {
+               return $this->factory->get('twofactor_backupcodes')->t('Second-factor backup codes');
+       }
+
+       public function prepare(INotification $notification, string $languageCode): INotification {
                if ($notification->getApp() !== 'twofactor_backupcodes') {
                        // Not my app => throw
                        throw new \InvalidArgumentException();
@@ -67,5 +87,4 @@ class Notifier implements INotifier {
                                throw new \InvalidArgumentException();
                }
        }
-
 }