Move DI dependency for Navigation\Notifications\Factory\FormattedNotify class
This commit is contained in:
parent
f1cbb41a60
commit
a1997d73c2
1 changed files with 16 additions and 13 deletions
|
@ -27,8 +27,8 @@ use Friendica\BaseFactory;
|
||||||
use Friendica\Content\Text\BBCode;
|
use Friendica\Content\Text\BBCode;
|
||||||
use Friendica\Core\L10n;
|
use Friendica\Core\L10n;
|
||||||
use Friendica\Core\Protocol;
|
use Friendica\Core\Protocol;
|
||||||
|
use Friendica\Core\Session\Capability\IHandleUserSessions;
|
||||||
use Friendica\Database\Database;
|
use Friendica\Database\Database;
|
||||||
use Friendica\DI;
|
|
||||||
use Friendica\Model\Contact;
|
use Friendica\Model\Contact;
|
||||||
use Friendica\Model\Item;
|
use Friendica\Model\Item;
|
||||||
use Friendica\Model\Post;
|
use Friendica\Model\Post;
|
||||||
|
@ -64,15 +64,18 @@ class FormattedNotify extends BaseFactory
|
||||||
private $baseUrl;
|
private $baseUrl;
|
||||||
/** @var L10n */
|
/** @var L10n */
|
||||||
private $l10n;
|
private $l10n;
|
||||||
|
/** @var IHandleUserSessions */
|
||||||
|
private $userSession;
|
||||||
|
|
||||||
public function __construct(LoggerInterface $logger, Database $dba, Repository\Notify $notification, BaseURL $baseUrl, L10n $l10n)
|
public function __construct(LoggerInterface $logger, Database $dba, Repository\Notify $notification, BaseURL $baseUrl, L10n $l10n, IHandleUserSessions $userSession)
|
||||||
{
|
{
|
||||||
parent::__construct($logger);
|
parent::__construct($logger);
|
||||||
|
|
||||||
$this->dba = $dba;
|
$this->dba = $dba;
|
||||||
$this->notify = $notification;
|
$this->notify = $notification;
|
||||||
$this->baseUrl = $baseUrl;
|
$this->baseUrl = $baseUrl;
|
||||||
$this->l10n = $l10n;
|
$this->l10n = $l10n;
|
||||||
|
$this->userSession = $userSession;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -211,7 +214,7 @@ class FormattedNotify extends BaseFactory
|
||||||
|
|
||||||
$formattedNotifications = new FormattedNotifies();
|
$formattedNotifications = new FormattedNotifies();
|
||||||
try {
|
try {
|
||||||
$Notifies = $this->notify->selectForUser(DI::userSession()->getLocalUserId(), $conditions, $params);
|
$Notifies = $this->notify->selectForUser($this->userSession->getLocalUserId(), $conditions, $params);
|
||||||
|
|
||||||
foreach ($Notifies as $Notify) {
|
foreach ($Notifies as $Notify) {
|
||||||
$formattedNotifications[] = new ValueObject\FormattedNotify(
|
$formattedNotifications[] = new ValueObject\FormattedNotify(
|
||||||
|
@ -244,7 +247,7 @@ class FormattedNotify extends BaseFactory
|
||||||
*/
|
*/
|
||||||
public function getNetworkList(bool $seen = false, int $start = 0, int $limit = BaseNotifications::DEFAULT_PAGE_LIMIT): FormattedNotifies
|
public function getNetworkList(bool $seen = false, int $start = 0, int $limit = BaseNotifications::DEFAULT_PAGE_LIMIT): FormattedNotifies
|
||||||
{
|
{
|
||||||
$condition = ['wall' => false, 'uid' => DI::userSession()->getLocalUserId()];
|
$condition = ['wall' => false, 'uid' => $this->userSession->getLocalUserId()];
|
||||||
|
|
||||||
if (!$seen) {
|
if (!$seen) {
|
||||||
$condition['unseen'] = true;
|
$condition['unseen'] = true;
|
||||||
|
@ -257,7 +260,7 @@ class FormattedNotify extends BaseFactory
|
||||||
$formattedNotifications = new FormattedNotifies();
|
$formattedNotifications = new FormattedNotifies();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$userPosts = Post::selectForUser(DI::userSession()->getLocalUserId(), $fields, $condition, $params);
|
$userPosts = Post::selectForUser($this->userSession->getLocalUserId(), $fields, $condition, $params);
|
||||||
while ($userPost = $this->dba->fetch($userPosts)) {
|
while ($userPost = $this->dba->fetch($userPosts)) {
|
||||||
$formattedNotifications[] = $this->createFromFormattedItem($this->formatItem($userPost));
|
$formattedNotifications[] = $this->createFromFormattedItem($this->formatItem($userPost));
|
||||||
}
|
}
|
||||||
|
@ -280,7 +283,7 @@ class FormattedNotify extends BaseFactory
|
||||||
*/
|
*/
|
||||||
public function getPersonalList(bool $seen = false, int $start = 0, int $limit = BaseNotifications::DEFAULT_PAGE_LIMIT): FormattedNotifies
|
public function getPersonalList(bool $seen = false, int $start = 0, int $limit = BaseNotifications::DEFAULT_PAGE_LIMIT): FormattedNotifies
|
||||||
{
|
{
|
||||||
$condition = ['wall' => false, 'uid' => DI::userSession()->getLocalUserId(), 'author-id' => DI::userSession()->getPublicContactId()];
|
$condition = ['wall' => false, 'uid' => $this->userSession->getLocalUserId(), 'author-id' => $this->userSession->getPublicContactId()];
|
||||||
|
|
||||||
if (!$seen) {
|
if (!$seen) {
|
||||||
$condition['unseen'] = true;
|
$condition['unseen'] = true;
|
||||||
|
@ -293,7 +296,7 @@ class FormattedNotify extends BaseFactory
|
||||||
$formattedNotifications = new FormattedNotifies();
|
$formattedNotifications = new FormattedNotifies();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$userPosts = Post::selectForUser(DI::userSession()->getLocalUserId(), $fields, $condition, $params);
|
$userPosts = Post::selectForUser($this->userSession->getLocalUserId(), $fields, $condition, $params);
|
||||||
while ($userPost = $this->dba->fetch($userPosts)) {
|
while ($userPost = $this->dba->fetch($userPosts)) {
|
||||||
$formattedNotifications[] = $this->createFromFormattedItem($this->formatItem($userPost));
|
$formattedNotifications[] = $this->createFromFormattedItem($this->formatItem($userPost));
|
||||||
}
|
}
|
||||||
|
@ -316,7 +319,7 @@ class FormattedNotify extends BaseFactory
|
||||||
*/
|
*/
|
||||||
public function getHomeList(bool $seen = false, int $start = 0, int $limit = BaseNotifications::DEFAULT_PAGE_LIMIT): FormattedNotifies
|
public function getHomeList(bool $seen = false, int $start = 0, int $limit = BaseNotifications::DEFAULT_PAGE_LIMIT): FormattedNotifies
|
||||||
{
|
{
|
||||||
$condition = ['wall' => true, 'uid' => DI::userSession()->getLocalUserId()];
|
$condition = ['wall' => true, 'uid' => $this->userSession->getLocalUserId()];
|
||||||
|
|
||||||
if (!$seen) {
|
if (!$seen) {
|
||||||
$condition['unseen'] = true;
|
$condition['unseen'] = true;
|
||||||
|
@ -329,7 +332,7 @@ class FormattedNotify extends BaseFactory
|
||||||
$formattedNotifications = new FormattedNotifies();
|
$formattedNotifications = new FormattedNotifies();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$userPosts = Post::selectForUser(DI::userSession()->getLocalUserId(), $fields, $condition, $params);
|
$userPosts = Post::selectForUser($this->userSession->getLocalUserId(), $fields, $condition, $params);
|
||||||
while ($userPost = $this->dba->fetch($userPosts)) {
|
while ($userPost = $this->dba->fetch($userPosts)) {
|
||||||
$formattedItem = $this->formatItem($userPost);
|
$formattedItem = $this->formatItem($userPost);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue