From 49c47008d189617ec989b04c8ec42b3c1484e87f Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 19 May 2022 09:08:04 +0000 Subject: [PATCH] Convert class calls into DI calls --- src/Model/Post/UserNotification.php | 4 ++-- src/Navigation/Notifications/Factory/Notification.php | 6 ++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/Model/Post/UserNotification.php b/src/Model/Post/UserNotification.php index f4e700f0bc..d16ec4936f 100644 --- a/src/Model/Post/UserNotification.php +++ b/src/Model/Post/UserNotification.php @@ -308,7 +308,7 @@ class UserNotification return; } - $notification = (new Notifications\Factory\Notification(DI::baseUrl(), DI::l10n(), DI::localRelationship(), DI::logger()))->createForUser( + $notification = DI::notificationFactory()->createForUser( $uid, $item['vid'], $type, @@ -336,7 +336,7 @@ class UserNotification */ public static function insertNotification(int $actor, string $verb, int $uid): bool { - $notification = (new Notifications\Factory\Notification(DI::baseUrl(), DI::l10n(), DI::localRelationship(), DI::logger()))->createForRelationship( + $notification = DI::notificationFactory()->createForRelationship( $uid, $actor, $verb diff --git a/src/Navigation/Notifications/Factory/Notification.php b/src/Navigation/Notifications/Factory/Notification.php index a41ba24ce1..b2132beaff 100644 --- a/src/Navigation/Notifications/Factory/Notification.php +++ b/src/Navigation/Notifications/Factory/Notification.php @@ -30,8 +30,6 @@ use Friendica\Content\Text\Plaintext; use Friendica\Core\Cache\Enum\Duration; use Friendica\Core\Cache\Capability\ICanCache; use Friendica\Core\L10n; -use Friendica\Core\System; -use Friendica\DI; use Friendica\Model\Contact; use Friendica\Model\Post; use Friendica\Model\Verb; @@ -51,14 +49,14 @@ class Notification extends BaseFactory implements ICanCreateFromTableRow /** @var ICanCache */ private $cache; - public function __construct(\Friendica\App\BaseURL $baseUrl, \Friendica\Core\L10n $l10n, \Friendica\Contact\LocalRelationship\Repository\LocalRelationship $localRelationshipRepo, LoggerInterface $logger) + public function __construct(\Friendica\App\BaseURL $baseUrl, \Friendica\Core\L10n $l10n, \Friendica\Contact\LocalRelationship\Repository\LocalRelationship $localRelationshipRepo, LoggerInterface $logger, ICanCache $cache) { parent::__construct($logger); $this->baseUrl = $baseUrl; $this->l10n = $l10n; $this->localRelationshipRepo = $localRelationshipRepo; - $this->cache = DI::cache(); // @todo Add the correct mechanism for class construction here + $this->cache = $cache; } public function createFromTableRow(array $row): Entity\Notification -- 2.39.5