]> source.dussan.org Git - nextcloud-server.git/commitdiff
Update Federated sharing notifier
authorJoas Schilling <coding@schilljs.com>
Fri, 12 Apr 2019 11:48:53 +0000 (13:48 +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/federatedfilesharing/appinfo/app.php
apps/federatedfilesharing/lib/Notifier.php

index f941987365f69feb1748f6e7dc99f83a5de42f8e..bd46f9824f244f2b104515c6aa808d594d178627 100644 (file)
@@ -29,15 +29,7 @@ $app = new \OCA\FederatedFileSharing\AppInfo\Application();
 $eventDispatcher = \OC::$server->getEventDispatcher();
 
 $manager = \OC::$server->getNotificationManager();
-$manager->registerNotifier(function() {
-       return \OC::$server->query(Notifier::class);
-}, function() {
-       $l = \OC::$server->getL10N('files_sharing');
-       return [
-               'id' => 'files_sharing',
-               'name' => $l->t('Federated sharing'),
-       ];
-});
+$manager->registerNotifier(Notifier::class);
 
 $federatedShareProvider = $app->getFederatedShareProvider();
 
index 03491f20af6f41bbd7bbaf1dbd511b6571b20564..02a46d65bba38b8d377e9aa7185d7ef7f2c98e8b 100644 (file)
@@ -59,13 +59,33 @@ class Notifier implements INotifier {
                $this->cloudIdManager = $cloudIdManager;
        }
 
+       /**
+        * Identifier of the notifier, only use [a-z0-9_]
+        *
+        * @return string
+        * @since 17.0.0
+        */
+       public function getID(): string {
+               return 'federatedfilesharing';
+       }
+
+       /**
+        * Human readable name describing the notifier
+        *
+        * @return string
+        * @since 17.0.0
+        */
+       public function getName(): string {
+               return $this->factory->get('federatedfilesharing')->t('Federated sharing');
+       }
+
        /**
         * @param INotification $notification
         * @param string $languageCode The code of the language that should be used to prepare the notification
         * @return INotification
         * @throws \InvalidArgumentException
         */
-       public function prepare(INotification $notification, $languageCode) {
+       public function prepare(INotification $notification, string $languageCode): INotification {
                if ($notification->getApp() !== 'files_sharing') {
                        // Not my app => throw
                        throw new \InvalidArgumentException();