From 2c0db2f0439aee490a452e11cf46d3d4c6b7e7d4 Mon Sep 17 00:00:00 2001 From: Art4 Date: Sun, 10 Nov 2024 16:09:30 +0000 Subject: [PATCH] Replace calls for App::setCurrentTheme() with AppHelper --- src/Module/Admin/Themes/Embed.php | 23 +++++++++++++---------- src/Module/Media/Attachment/Browser.php | 17 +++++++++-------- src/Module/Media/Photo/Browser.php | 16 +++++++++------- 3 files changed, 31 insertions(+), 25 deletions(-) diff --git a/src/Module/Admin/Themes/Embed.php b/src/Module/Admin/Themes/Embed.php index 3337f91d80..00a79db54d 100644 --- a/src/Module/Admin/Themes/Embed.php +++ b/src/Module/Admin/Themes/Embed.php @@ -7,7 +7,10 @@ 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\Renderer; use Friendica\DI; @@ -19,21 +22,21 @@ use Psr\Log\LoggerInterface; class Embed extends BaseAdmin { - /** @var App */ - protected $app; - /** @var App\Mode */ + /** @var AppHelper */ + protected $appHelper; + /** @var 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); - $this->app = $app; - $this->mode = $mode; + $this->appHelper = $appHelper; + $this->mode = $mode; $theme = Strings::sanitizeFilePathItem($this->parameters['theme']); 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"; if (function_exists('theme_admin_post')) { 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"; if (function_exists('theme_admin')) { - $admin_form = theme_admin($this->app); + $admin_form = theme_admin($this->appHelper); } } diff --git a/src/Module/Media/Attachment/Browser.php b/src/Module/Media/Attachment/Browser.php index cff3e18243..fd46499552 100644 --- a/src/Module/Media/Attachment/Browser.php +++ b/src/Module/Media/Attachment/Browser.php @@ -7,12 +7,13 @@ namespace Friendica\Module\Media\Attachment; -use Friendica\App; +use Friendica\App\Arguments; +use Friendica\App\BaseURL; +use Friendica\AppHelper; use Friendica\BaseModule; use Friendica\Core\L10n; use Friendica\Core\Renderer; use Friendica\Core\Session\Capability\IHandleUserSessions; -use Friendica\Core\System; use Friendica\Model\Attach; use Friendica\Module\Response; use Friendica\Network\HTTPException\UnauthorizedException; @@ -27,15 +28,15 @@ class Browser extends BaseModule { /** @var IHandleUserSessions */ protected $session; - /** @var App */ - protected $app; + /** @var AppHelper */ + 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); - $this->session = $session; - $this->app = $app; + $this->session = $session; + $this->appHelper = $appHelper; } 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 $theme = Strings::sanitizeFilePathItem($request['theme'] ?? ''); 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()]); diff --git a/src/Module/Media/Photo/Browser.php b/src/Module/Media/Photo/Browser.php index aa412530b7..408ba575d1 100644 --- a/src/Module/Media/Photo/Browser.php +++ b/src/Module/Media/Photo/Browser.php @@ -7,7 +7,9 @@ namespace Friendica\Module\Media\Photo; -use Friendica\App; +use Friendica\App\Arguments; +use Friendica\App\BaseURL; +use Friendica\AppHelper; use Friendica\BaseModule; use Friendica\Core\L10n; use Friendica\Core\Renderer; @@ -28,15 +30,15 @@ class Browser extends BaseModule { /** @var IHandleUserSessions */ protected $session; - /** @var App */ - protected $app; + /** @var AppHelper */ + 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); - $this->session = $session; - $this->app = $app; + $this->session = $session; + $this->appHelper = $appHelper; } 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 $theme = Strings::sanitizeFilePathItem($request['theme'] ?? ''); if ($theme && is_file("view/theme/$theme/config.php")) { - $this->app->setCurrentTheme($theme); + $this->appHelper->setCurrentTheme($theme); } $album = $this->parameters['album'] ?? null;