Introduce new DI container

- Adding Friendica\DI class for getting dynamic classes
- Replacing BaseObject::getApp() with this class
This commit is contained in:
nupplaPhil 2019-12-15 22:34:11 +01:00
parent a9220aa83b
commit 1de3f186d7
No known key found for this signature in database
GPG key ID: D8365C3D36B77D90
132 changed files with 377 additions and 270 deletions

View file

@ -13,6 +13,7 @@ use Friendica\Core\Hook;
use Friendica\Core\L10n;
use Friendica\Core\Renderer;
use Friendica\Core\Session;
use Friendica\DI;
use Friendica\Module\Register;
use Friendica\Util\Strings;
@ -25,7 +26,7 @@ class Login extends BaseModule
{
public static function content(array $parameters = [])
{
$a = self::getApp();
$a = DI::app();
if (local_user()) {
$a->internalRedirect();
@ -57,7 +58,7 @@ class Login extends BaseModule
/** @var Authentication $authentication */
$authentication = self::getClass(Authentication::class);
$authentication->withPassword(
self::getApp(),
DI::app(),
trim($_POST['username']),
trim($_POST['password']),
!empty($_POST['remember'])
@ -81,7 +82,7 @@ class Login extends BaseModule
*/
public static function form($return_path = null, $register = false, $hiddens = [])
{
$a = self::getApp();
$a = DI::app();
$o = '';
$noid = Config::get('system', 'no_openid');
@ -133,7 +134,7 @@ class Login extends BaseModule
$o .= Renderer::replaceMacros(
$tpl,
[
'$dest_url' => self::getApp()->getBaseURL(true) . '/login',
'$dest_url' => DI::app()->getBaseURL(true) . '/login',
'$logout' => L10n::t('Logout'),
'$login' => L10n::t('Login'),

View file

@ -12,6 +12,7 @@ use Friendica\Core\Hook;
use Friendica\Core\L10n;
use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\DI;
use Friendica\Model\Profile;
/**
@ -39,7 +40,7 @@ class Logout extends BaseModule
System::externalRedirect($visitor_home);
} else {
info(L10n::t('Logged out.'));
self::getApp()->internalRedirect();
DI::app()->internalRedirect();
}
}
}

View file

@ -7,6 +7,7 @@ use Friendica\App\Authentication;
use Friendica\Core\L10n;
use Friendica\Core\Renderer;
use Friendica\Core\Session;
use Friendica\DI;
use Friendica\Model\TwoFactor\RecoveryCode;
/**
@ -32,7 +33,7 @@ class Recovery extends BaseModule
if (($_POST['action'] ?? '') == 'recover') {
self::checkFormSecurityTokenRedirectOnError('2fa', 'twofactor_recovery');
$a = self::getApp();
$a = DI::app();
$recovery_code = $_POST['recovery_code'] ?? '';
@ -54,12 +55,12 @@ class Recovery extends BaseModule
public static function content(array $parameters = [])
{
if (!local_user()) {
self::getApp()->internalRedirect();
DI::app()->internalRedirect();
}
// Already authenticated with 2FA token
if (Session::get('2fa')) {
self::getApp()->internalRedirect();
DI::app()->internalRedirect();
}
return Renderer::replaceMacros(Renderer::getMarkupTemplate('twofactor/recovery.tpl'), [

View file

@ -8,6 +8,7 @@ use Friendica\Core\L10n;
use Friendica\Core\PConfig;
use Friendica\Core\Renderer;
use Friendica\Core\Session;
use Friendica\DI;
use PragmaRX\Google2FA\Google2FA;
/**
@ -28,7 +29,7 @@ class Verify extends BaseModule
if (($_POST['action'] ?? '') == 'verify') {
self::checkFormSecurityTokenRedirectOnError('2fa', 'twofactor_verify');
$a = self::getApp();
$a = DI::app();
$code = $_POST['verify_code'] ?? '';
@ -51,12 +52,12 @@ class Verify extends BaseModule
public static function content(array $parameters = [])
{
if (!local_user()) {
self::getApp()->internalRedirect();
DI::app()->internalRedirect();
}
// Already authenticated with 2FA token
if (Session::get('2fa')) {
self::getApp()->internalRedirect();
DI::app()->internalRedirect();
}
return Renderer::replaceMacros(Renderer::getMarkupTemplate('twofactor/verify.tpl'), [