Create new DI shorthands for notification-related factories
This commit is contained in:
15
src/DI.php
15
src/DI.php
@@ -463,11 +463,26 @@ abstract class DI
|
||||
return self::$dice->create(Navigation\Notifications\Depository\Notification::class);
|
||||
}
|
||||
|
||||
public static function notificationFactory(): Navigation\Notifications\Factory\Notification
|
||||
{
|
||||
return self::$dice->create(Navigation\Notifications\Factory\Notification::class);
|
||||
}
|
||||
|
||||
public static function notify(): Navigation\Notifications\Depository\Notify
|
||||
{
|
||||
return self::$dice->create(Navigation\Notifications\Depository\Notify::class);
|
||||
}
|
||||
|
||||
public static function notifyFactory(): Navigation\Notifications\Factory\Notify
|
||||
{
|
||||
return self::$dice->create(Navigation\Notifications\Factory\Notify::class);
|
||||
}
|
||||
|
||||
public static function formattedNotificationFactory(): Navigation\Notifications\Factory\FormattedNotification
|
||||
{
|
||||
return self::$dice->create(Navigation\Notifications\Factory\FormattedNotification::class);
|
||||
}
|
||||
|
||||
//
|
||||
// "Protocol" namespace instances
|
||||
//
|
||||
|
||||
@@ -46,8 +46,7 @@ class Notifications extends BaseNotifications
|
||||
$notificationHeader = '';
|
||||
$notifications = [];
|
||||
|
||||
/** @var \Friendica\Navigation\Notifications\Factory\FormattedNotification $factory */
|
||||
$factory = DI::getDice()->create(\Friendica\Navigation\Notifications\Factory\FormattedNotification::class);
|
||||
$factory = DI::formattedNotificationFactory();
|
||||
|
||||
if ((DI::args()->get(1) == 'network')) {
|
||||
$notificationHeader = DI::l10n()->t('Network Notifications');
|
||||
|
||||
@@ -82,7 +82,7 @@ class PushSubscription
|
||||
}
|
||||
}
|
||||
|
||||
$message = (new Notifications\Factory\Notification(DI::logger()))->getMessageFromNotification($Notification, DI::baseUrl(), $l10n);
|
||||
$message = DI::notificationFactory()->getMessageFromNotification($Notification, DI::baseUrl(), $l10n);
|
||||
$title = $message['plain'] ?: '';
|
||||
|
||||
$push = Subscription::create([
|
||||
|
||||
Reference in New Issue
Block a user