UserSession class [6] - Refactor src/Module/ files without DI
This commit is contained in:
parent
bf39b5a948
commit
22198ea495
8 changed files with 74 additions and 38 deletions
|
@ -24,7 +24,7 @@ namespace Friendica\Module\Filer;
|
|||
use Friendica\App;
|
||||
use Friendica\BaseModule;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Core\Session\Capability\IHandleUserSessions;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Model\Post;
|
||||
|
@ -41,12 +41,15 @@ class RemoveTag extends BaseModule
|
|||
{
|
||||
/** @var SystemMessages */
|
||||
private $systemMessages;
|
||||
/** @var IHandleUserSessions */
|
||||
private $userSession;
|
||||
|
||||
public function __construct(SystemMessages $systemMessages, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = [])
|
||||
public function __construct(SystemMessages $systemMessages, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, IHandleUserSessions $userSession, array $server, array $parameters = [])
|
||||
{
|
||||
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
|
||||
|
||||
$this->systemMessages = $systemMessages;
|
||||
$this->userSession = $userSession;
|
||||
}
|
||||
|
||||
protected function post(array $request = [])
|
||||
|
@ -56,7 +59,7 @@ class RemoveTag extends BaseModule
|
|||
|
||||
protected function content(array $request = []): string
|
||||
{
|
||||
if (!Session::getLocalUser()) {
|
||||
if (!$this->userSession->getLocalUserId()) {
|
||||
throw new HTTPException\ForbiddenException();
|
||||
}
|
||||
|
||||
|
@ -108,7 +111,7 @@ class RemoveTag extends BaseModule
|
|||
return 404;
|
||||
}
|
||||
|
||||
if (!Post\Category::deleteFileByURIId($item['uri-id'], Session::getLocalUser(), $type, $term)) {
|
||||
if (!Post\Category::deleteFileByURIId($item['uri-id'], $this->userSession->getLocalUserId(), $type, $term)) {
|
||||
$this->systemMessages->addNotice($this->l10n->t('Item was not removed'));
|
||||
return 500;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue