Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Adjust notifier to Nextcloud 17
Signed-off-by: Joas Schilling <[email protected]>
  • Loading branch information
nickvergessen committed Jul 18, 2019
commit b2f41fc736b612426b70eb4b98fcd7146a943a98
11 changes: 1 addition & 10 deletions lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,16 +129,7 @@ public function register(): void {

protected function registerNotifier(IServerContainer $server): void {
$manager = $server->getNotificationManager();
$manager->registerNotifier(function() use ($server) {
return $server->query(Notifier::class);
}, function() use ($server) {
$l = $server->getL10N('spreed');

return [
'id' => 'spreed',
'name' => $l->t('Talk'),
];
});
$manager->registerNotifierService(Notifier::class);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Register with the class name, instead of a closure

}

protected function registerCollaborationResourceProvider(IServerContainer $server): void {
Expand Down
22 changes: 21 additions & 1 deletion lib/Notification/Notifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,34 @@ public function __construct(IFactory $lFactory,
$this->definitions = $definitions;
}

/**
* Identifier of the notifier, only use [a-z0-9_]
*
* @return string
* @since 17.0.0
*/
public function getID(): string {
return 'talk';
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New method in 17, replacing the id return of the info closure from the old registration way

}

/**
* Human readable name describing the notifier
*
* @return string
* @since 17.0.0
*/
public function getName(): string {
return $this->lFactory->get('spreed')->t('Talk');
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New method in 17, replacing the name return of the info closure from the old registration way

}

/**
* @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
* @since 9.0.0
*/
public function prepare(INotification $notification, $languageCode): INotification {
public function prepare(INotification $notification, string $languageCode): INotification {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Type hint for $languageCode is new, and the : INotification return type is enforced now too.

if ($notification->getApp() !== 'spreed') {
throw new \InvalidArgumentException('Incorrect app');
}
Expand Down