Replace calls for App::setCurrentTheme() with AppHelper

This commit is contained in:
Art4 2024-11-10 16:09:30 +00:00
parent c495461ffb
commit 2c0db2f043
3 changed files with 31 additions and 25 deletions

View file

@ -7,7 +7,10 @@
namespace Friendica\Module\Admin\Themes; namespace Friendica\Module\Admin\Themes;
use Friendica\App; use Friendica\App\Arguments;
use Friendica\App\BaseURL;
use Friendica\App\Mode;
use Friendica\AppHelper;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\DI; use Friendica\DI;
@ -19,21 +22,21 @@ use Psr\Log\LoggerInterface;
class Embed extends BaseAdmin class Embed extends BaseAdmin
{ {
/** @var App */ /** @var AppHelper */
protected $app; protected $appHelper;
/** @var App\Mode */ /** @var Mode */
protected $mode; protected $mode;
public function __construct(App $app, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, App\Mode $mode, array $server, array $parameters = []) public function __construct(AppHelper $appHelper, L10n $l10n, BaseURL $baseUrl, Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, Mode $mode, array $server, array $parameters = [])
{ {
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
$this->app = $app; $this->appHelper = $appHelper;
$this->mode = $mode; $this->mode = $mode;
$theme = Strings::sanitizeFilePathItem($this->parameters['theme']); $theme = Strings::sanitizeFilePathItem($this->parameters['theme']);
if (is_file("view/theme/$theme/config.php")) { if (is_file("view/theme/$theme/config.php")) {
$this->app->setCurrentTheme($theme); $this->appHelper->setCurrentTheme($theme);
} }
} }
@ -46,7 +49,7 @@ class Embed extends BaseAdmin
require_once "view/theme/$theme/config.php"; require_once "view/theme/$theme/config.php";
if (function_exists('theme_admin_post')) { if (function_exists('theme_admin_post')) {
self::checkFormSecurityTokenRedirectOnError('/admin/themes/' . $theme . '/embed?mode=minimal', 'admin_theme_settings'); self::checkFormSecurityTokenRedirectOnError('/admin/themes/' . $theme . '/embed?mode=minimal', 'admin_theme_settings');
theme_admin_post($this->app); theme_admin_post($this->appHelper);
} }
} }
@ -72,7 +75,7 @@ class Embed extends BaseAdmin
require_once "view/theme/$theme/config.php"; require_once "view/theme/$theme/config.php";
if (function_exists('theme_admin')) { if (function_exists('theme_admin')) {
$admin_form = theme_admin($this->app); $admin_form = theme_admin($this->appHelper);
} }
} }

View file

@ -7,12 +7,13 @@
namespace Friendica\Module\Media\Attachment; namespace Friendica\Module\Media\Attachment;
use Friendica\App; use Friendica\App\Arguments;
use Friendica\App\BaseURL;
use Friendica\AppHelper;
use Friendica\BaseModule; use Friendica\BaseModule;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\Core\Session\Capability\IHandleUserSessions; use Friendica\Core\Session\Capability\IHandleUserSessions;
use Friendica\Core\System;
use Friendica\Model\Attach; use Friendica\Model\Attach;
use Friendica\Module\Response; use Friendica\Module\Response;
use Friendica\Network\HTTPException\UnauthorizedException; use Friendica\Network\HTTPException\UnauthorizedException;
@ -27,15 +28,15 @@ class Browser extends BaseModule
{ {
/** @var IHandleUserSessions */ /** @var IHandleUserSessions */
protected $session; protected $session;
/** @var App */ /** @var AppHelper */
protected $app; protected $appHelper;
public function __construct(L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, IHandleUserSessions $session, App $app, array $server, array $parameters = []) public function __construct(L10n $l10n, BaseURL $baseUrl, Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, IHandleUserSessions $session, AppHelper $appHelper, array $server, array $parameters = [])
{ {
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
$this->session = $session; $this->session = $session;
$this->app = $app; $this->appHelper = $appHelper;
} }
protected function content(array $request = []): string protected function content(array $request = []): string
@ -47,7 +48,7 @@ class Browser extends BaseModule
// Needed to match the correct template in a module that uses a different theme than the user/site/default // Needed to match the correct template in a module that uses a different theme than the user/site/default
$theme = Strings::sanitizeFilePathItem($request['theme'] ?? ''); $theme = Strings::sanitizeFilePathItem($request['theme'] ?? '');
if ($theme && is_file("view/theme/$theme/config.php")) { if ($theme && is_file("view/theme/$theme/config.php")) {
$this->app->setCurrentTheme($theme); $this->appHelper->setCurrentTheme($theme);
} }
$files = Attach::selectToArray(['id', 'filename', 'filetype'], ['uid' => $this->session->getLocalUserId()]); $files = Attach::selectToArray(['id', 'filename', 'filetype'], ['uid' => $this->session->getLocalUserId()]);

View file

@ -7,7 +7,9 @@
namespace Friendica\Module\Media\Photo; namespace Friendica\Module\Media\Photo;
use Friendica\App; use Friendica\App\Arguments;
use Friendica\App\BaseURL;
use Friendica\AppHelper;
use Friendica\BaseModule; use Friendica\BaseModule;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
@ -28,15 +30,15 @@ class Browser extends BaseModule
{ {
/** @var IHandleUserSessions */ /** @var IHandleUserSessions */
protected $session; protected $session;
/** @var App */ /** @var AppHelper */
protected $app; protected $appHelper;
public function __construct(L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, IHandleUserSessions $session, App $app, array $server, array $parameters = []) public function __construct(L10n $l10n, BaseURL $baseUrl, Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, IHandleUserSessions $session, AppHelper $appHelper, array $server, array $parameters = [])
{ {
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
$this->session = $session; $this->session = $session;
$this->app = $app; $this->appHelper = $appHelper;
} }
protected function content(array $request = []): string protected function content(array $request = []): string
@ -48,7 +50,7 @@ class Browser extends BaseModule
// Needed to match the correct template in a module that uses a different theme than the user/site/default // Needed to match the correct template in a module that uses a different theme than the user/site/default
$theme = Strings::sanitizeFilePathItem($request['theme'] ?? ''); $theme = Strings::sanitizeFilePathItem($request['theme'] ?? '');
if ($theme && is_file("view/theme/$theme/config.php")) { if ($theme && is_file("view/theme/$theme/config.php")) {
$this->app->setCurrentTheme($theme); $this->appHelper->setCurrentTheme($theme);
} }
$album = $this->parameters['album'] ?? null; $album = $this->parameters['album'] ?? null;