Revert "Replace Module::init() with Constructors"

This commit is contained in:
Hypolite Petovan 2021-11-19 07:23:23 -05:00 committed by GitHub
parent 0b6e0566d7
commit 89d6c89b67
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
43 changed files with 921 additions and 1225 deletions

View file

@ -21,32 +21,18 @@
namespace Friendica\Module\Admin\Themes;
use Friendica\App;
use Friendica\Core\L10n;
use Friendica\Core\Renderer;
use Friendica\DI;
use Friendica\Module\BaseAdmin;
use Friendica\Util\Strings;
class Embed extends BaseAdmin
{
/** @var App */
protected $app;
/** @var App\BaseURL */
protected $baseUrl;
/** @var App\Mode */
protected $mode;
public function __construct(App $app, App\BaseURL $baseUrl, App\Mode $mode, L10n $l10n, array $parameters = [])
public function init()
{
parent::__construct($l10n, $parameters);
$this->app = $app;
$this->baseUrl = $baseUrl;
$this->mode = $mode;
$theme = Strings::sanitizeFilePathItem($this->parameters['theme']);
if (is_file("view/theme/$theme/config.php")) {
$this->app->setCurrentTheme($theme);
DI::app()->setCurrentTheme($theme);
}
}
@ -59,15 +45,15 @@ 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(DI::app());
}
}
if ($this->mode->isAjax()) {
if (DI::mode()->isAjax()) {
return;
}
$this->baseUrl->redirect('admin/themes/' . $theme . '/embed?mode=minimal');
DI::baseUrl()->redirect('admin/themes/' . $theme . '/embed?mode=minimal');
}
public function content(): string
@ -76,7 +62,7 @@ class Embed extends BaseAdmin
$theme = Strings::sanitizeFilePathItem($this->parameters['theme']);
if (!is_dir("view/theme/$theme")) {
notice($this->t('Unknown theme.'));
notice(DI::l10n()->t('Unknown theme.'));
return '';
}
@ -85,7 +71,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(DI::app());
}
}