Replace BaseObject class with DI::* calls

This commit is contained in:
Philipp Holzer 2019-12-15 23:28:01 +01:00
parent 1de3f186d7
commit 388b963714
No known key found for this signature in database
GPG key ID: D8365C3D36B77D90
98 changed files with 321 additions and 440 deletions

View file

@ -34,7 +34,6 @@
use Dice\Dice; use Dice\Dice;
use Friendica\App\Mode; use Friendica\App\Mode;
use Friendica\BaseObject;
use Friendica\Util\ExAuth; use Friendica\Util\ExAuth;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
@ -57,7 +56,7 @@ require dirname(__DIR__) . '/vendor/autoload.php';
$dice = (new Dice())->addRules(include __DIR__ . '/../static/dependencies.config.php'); $dice = (new Dice())->addRules(include __DIR__ . '/../static/dependencies.config.php');
$dice = $dice->addRule(LoggerInterface::class,['constructParams' => ['auth_ejabberd']]); $dice = $dice->addRule(LoggerInterface::class,['constructParams' => ['auth_ejabberd']]);
BaseObject::setDependencyInjection($dice); \Friendica\DI::init($dice);
$appMode = $dice->create(Mode::class); $appMode = $dice->create(Mode::class);

View file

@ -36,7 +36,7 @@ require dirname(__DIR__) . '/vendor/autoload.php';
$dice = (new Dice())->addRules(include __DIR__ . '/../static/dependencies.config.php'); $dice = (new Dice())->addRules(include __DIR__ . '/../static/dependencies.config.php');
$dice = $dice->addRule(LoggerInterface::class,['constructParams' => ['daemon']]); $dice = $dice->addRule(LoggerInterface::class,['constructParams' => ['daemon']]);
\Friendica\BaseObject::setDependencyInjection($dice); \Friendica\DI::init($dice);
$a = \Friendica\DI::app(); $a = \Friendica\DI::app();
if ($a->getMode()->isInstall()) { if ($a->getMode()->isInstall()) {

View file

@ -7,7 +7,6 @@
use Dice\Dice; use Dice\Dice;
use Friendica\App; use Friendica\App;
use Friendica\BaseObject;
use Friendica\Core\Config; use Friendica\Core\Config;
use Friendica\Core\Update; use Friendica\Core\Update;
use Friendica\Core\Worker; use Friendica\Core\Worker;
@ -35,7 +34,7 @@ require dirname(__DIR__) . '/vendor/autoload.php';
$dice = (new Dice())->addRules(include __DIR__ . '/../static/dependencies.config.php'); $dice = (new Dice())->addRules(include __DIR__ . '/../static/dependencies.config.php');
$dice = $dice->addRule(LoggerInterface::class,['constructParams' => ['worker']]); $dice = $dice->addRule(LoggerInterface::class,['constructParams' => ['worker']]);
BaseObject::setDependencyInjection($dice); \Friendica\DI::init($dice);
$a = Friendica\DI::app(); $a = Friendica\DI::app();
// Check the database structure and possibly fixes it // Check the database structure and possibly fixes it

View file

@ -18,7 +18,6 @@
*/ */
use Friendica\App; use Friendica\App;
use Friendica\BaseObject;
use Friendica\Core\Config; use Friendica\Core\Config;
use Friendica\Core\PConfig; use Friendica\Core\PConfig;
use Friendica\Core\Protocol; use Friendica\Core\Protocol;

View file

@ -7,12 +7,10 @@
*/ */
use Friendica\App; use Friendica\App;
use Friendica\BaseObject;
use Friendica\Content\ContactSelector; use Friendica\Content\ContactSelector;
use Friendica\Content\Feature; use Friendica\Content\Feature;
use Friendica\Content\Text\BBCode; use Friendica\Content\Text\BBCode;
use Friendica\Content\Text\HTML; use Friendica\Content\Text\HTML;
use Friendica\App\Authentication;
use Friendica\Core\Config; use Friendica\Core\Config;
use Friendica\Core\Hook; use Friendica\Core\Hook;
use Friendica\Core\L10n; use Friendica\Core\L10n;
@ -23,11 +21,11 @@ use Friendica\Core\Session;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\Core\Worker; use Friendica\Core\Worker;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact; use Friendica\Model\Contact;
use Friendica\Model\Group; use Friendica\Model\Group;
use Friendica\Model\Item; use Friendica\Model\Item;
use Friendica\Model\Mail; use Friendica\Model\Mail;
use Friendica\Model\Notify;
use Friendica\Model\Photo; use Friendica\Model\Photo;
use Friendica\Model\Profile; use Friendica\Model\Profile;
use Friendica\Model\User; use Friendica\Model\User;
@ -254,9 +252,7 @@ function api_login(App $a)
throw new UnauthorizedException("This API requires login"); throw new UnauthorizedException("This API requires login");
} }
/** @var Authentication $authentication */ DI::auth()->setForUser($a, $record);
$authentication = BaseObject::getClass(Authentication::class);
$authentication->setForUser($a, $record);
$_SESSION["allow_api"] = true; $_SESSION["allow_api"] = true;
@ -5909,10 +5905,7 @@ function api_friendica_notification($type)
if ($a->argc!==3) { if ($a->argc!==3) {
throw new BadRequestException("Invalid argument count"); throw new BadRequestException("Invalid argument count");
} }
/** @var Notify $nm */ $notes = DI::notify()->getAll([], ['seen' => 'ASC', 'date' => 'DESC'], 50);
$nm = BaseObject::getClass(Notify::class);
$notes = $nm->getAll([], ['seen' => 'ASC', 'date' => 'DESC'], 50);
if ($type == "xml") { if ($type == "xml") {
$xmlnotes = []; $xmlnotes = [];
@ -5954,8 +5947,7 @@ function api_friendica_notification_seen($type)
$id = (!empty($_REQUEST['id']) ? intval($_REQUEST['id']) : 0); $id = (!empty($_REQUEST['id']) ? intval($_REQUEST['id']) : 0);
/** @var Notify $nm */ $nm = DI::notify();
$nm = BaseObject::getClass(Notify::class);
$note = $nm->getByID($id); $note = $nm->getByID($id);
if (is_null($note)) { if (is_null($note)) {
throw new BadRequestException("Invalid argument"); throw new BadRequestException("Invalid argument");

View file

@ -4,10 +4,8 @@
*/ */
use Friendica\App; use Friendica\App;
use Friendica\BaseObject;
use Friendica\Content\ContactSelector; use Friendica\Content\ContactSelector;
use Friendica\Content\Feature; use Friendica\Content\Feature;
use Friendica\Content\Item as ContentItem;
use Friendica\Content\Pager; use Friendica\Content\Pager;
use Friendica\Content\Text\BBCode; use Friendica\Content\Text\BBCode;
use Friendica\Core\Config; use Friendica\Core\Config;
@ -20,6 +18,7 @@ use Friendica\Core\Renderer;
use Friendica\Core\Session; use Friendica\Core\Session;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact; use Friendica\Model\Contact;
use Friendica\Model\Item; use Friendica\Model\Item;
use Friendica\Model\Profile; use Friendica\Model\Profile;
@ -141,8 +140,7 @@ function localize_item(&$item)
During the further steps of the database restructuring I would like to address this issue. During the further steps of the database restructuring I would like to address this issue.
*/ */
/** @var Activity $activity */ $activity = DI::activity();
$activity = BaseObject::getClass(Activity::class);
$xmlhead = "<" . "?xml version='1.0' encoding='UTF-8' ?" . ">"; $xmlhead = "<" . "?xml version='1.0' encoding='UTF-8' ?" . ">";
if ($activity->match($item['verb'], Activity::LIKE) if ($activity->match($item['verb'], Activity::LIKE)
@ -399,8 +397,7 @@ function count_descendants($item) {
function visible_activity($item) { function visible_activity($item) {
/** @var Activity $activity */ $activity = DI::activity();
$activity = BaseObject::getClass(Activity::class);
if (empty($item['verb']) || $activity->isHidden($item['verb'])) { if (empty($item['verb']) || $activity->isHidden($item['verb'])) {
return false; return false;
@ -668,10 +665,7 @@ function conversation(App $a, array $items, Pager $pager, $mode, $update, $previ
$body = Item::prepareBody($item, true, $preview); $body = Item::prepareBody($item, true, $preview);
/** @var ContentItem $contItem */ list($categories, $folders) = DI::contentItem()->determineCategoriesTerms($item);
$contItem = BaseObject::getClass(ContentItem::class);
list($categories, $folders) = $contItem->determineCategoriesTerms($item);
if (!empty($item['content-warning']) && PConfig::get(local_user(), 'system', 'disable_cw', false)) { if (!empty($item['content-warning']) && PConfig::get(local_user(), 'system', 'disable_cw', false)) {
$title = ucfirst($item['content-warning']); $title = ucfirst($item['content-warning']);
@ -1031,10 +1025,7 @@ function builtin_activity_puller($item, &$conv_responses) {
return; return;
} }
/** @var Activity $activity */ if (!empty($item['verb']) && DI::activity()->match($item['verb'], $verb) && ($item['id'] != $item['parent'])) {
$activity = BaseObject::getClass(Activity::class);
if (!empty($item['verb']) && $activity->match($item['verb'], $verb) && ($item['id'] != $item['parent'])) {
$author = ['uid' => 0, 'id' => $item['author-id'], $author = ['uid' => 0, 'id' => $item['author-id'],
'network' => $item['author-network'], 'url' => $item['author-link']]; 'network' => $item['author-network'], 'url' => $item['author-link']];
$url = Contact::magicLinkByContact($author); $url = Contact::magicLinkByContact($author);

View file

@ -3,13 +3,10 @@
* @file include/items.php * @file include/items.php
*/ */
use Friendica\BaseObject;
use Friendica\Content\Feature;
use Friendica\Core\Config; use Friendica\Core\Config;
use Friendica\Core\Hook; use Friendica\Core\Hook;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\Core\Logger; use Friendica\Core\Logger;
use Friendica\Core\PConfig;
use Friendica\Core\Protocol; use Friendica\Core\Protocol;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\Core\System; use Friendica\Core\System;
@ -19,11 +16,9 @@ use Friendica\Model\Item;
use Friendica\Protocol\DFRN; use Friendica\Protocol\DFRN;
use Friendica\Protocol\Feed; use Friendica\Protocol\Feed;
use Friendica\Protocol\OStatus; use Friendica\Protocol\OStatus;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Network; use Friendica\Util\Network;
use Friendica\Util\ParseUrl; use Friendica\Util\ParseUrl;
use Friendica\Util\Strings; use Friendica\Util\Strings;
use Friendica\Util\Temporal;
require_once __DIR__ . '/../mod/share.php'; require_once __DIR__ . '/../mod/share.php';

View file

@ -15,7 +15,7 @@ require __DIR__ . '/vendor/autoload.php';
$dice = (new Dice())->addRules(include __DIR__ . '/static/dependencies.config.php'); $dice = (new Dice())->addRules(include __DIR__ . '/static/dependencies.config.php');
$dice = $dice->addRule(Friendica\App\Mode::class, ['call' => [['determineRunMode', [false, $_SERVER], Dice::CHAIN_CALL]]]); $dice = $dice->addRule(Friendica\App\Mode::class, ['call' => [['determineRunMode', [false, $_SERVER], Dice::CHAIN_CALL]]]);
\Friendica\BaseObject::setDependencyInjection($dice); \Friendica\DI::init($dice);
$a = \Friendica\DI::app(); $a = \Friendica\DI::app();

View file

@ -5,14 +5,13 @@
*/ */
use Friendica\App; use Friendica\App;
use Friendica\BaseObject;
use Friendica\App\Authentication;
use Friendica\Core\Config; use Friendica\Core\Config;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\Core\Logger; use Friendica\Core\Logger;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\Core\Session; use Friendica\Core\Session;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Module\Security\Login; use Friendica\Module\Security\Login;
use Friendica\Protocol\DFRN; use Friendica\Protocol\DFRN;
use Friendica\Protocol\OStatus; use Friendica\Protocol\OStatus;
@ -22,9 +21,7 @@ use Friendica\Util\XML;
function dfrn_poll_init(App $a) function dfrn_poll_init(App $a)
{ {
/** @var Authentication $authentication */ DI::auth()->withSession($a);
$authentication = BaseObject::getClass(Authentication::class);
$authentication->withSession($a);
$dfrn_id = $_GET['dfrn_id'] ?? ''; $dfrn_id = $_GET['dfrn_id'] ?? '';
$type = ($_GET['type'] ?? '') ?: 'data'; $type = ($_GET['type'] ?? '') ?: 'data';

View file

@ -5,7 +5,6 @@
*/ */
use Friendica\App; use Friendica\App;
use Friendica\BaseObject;
use Friendica\Content\Nav; use Friendica\Content\Nav;
use Friendica\Content\Widget\CalendarExport; use Friendica\Content\Widget\CalendarExport;
use Friendica\Core\ACL; use Friendica\Core\ACL;
@ -19,6 +18,7 @@ use Friendica\Database\DBA;
use Friendica\Model\Event; use Friendica\Model\Event;
use Friendica\Model\Item; use Friendica\Model\Item;
use Friendica\Model\Profile; use Friendica\Model\Profile;
use Friendica\Module\Login;
use Friendica\Module\Security\Login; use Friendica\Module\Security\Login;
use Friendica\Util\ACLFormatter; use Friendica\Util\ACLFormatter;
use Friendica\Util\DateTimeFormat; use Friendica\Util\DateTimeFormat;
@ -150,8 +150,7 @@ function events_post(App $a)
if ($share) { if ($share) {
/** @var ACLFormatter $aclFormatter */ $aclFormatter = \Friendica\DI::aclFormatter();
$aclFormatter = BaseObject::getClass(ACLFormatter::class);
$str_group_allow = $aclFormatter->toString($_POST['group_allow'] ?? ''); $str_group_allow = $aclFormatter->toString($_POST['group_allow'] ?? '');
$str_contact_allow = $aclFormatter->toString($_POST['contact_allow'] ?? ''); $str_contact_allow = $aclFormatter->toString($_POST['contact_allow'] ?? '');

View file

@ -16,7 +16,6 @@
*/ */
use Friendica\App; use Friendica\App;
use Friendica\BaseObject;
use Friendica\Content\Pager; use Friendica\Content\Pager;
use Friendica\Content\Text\BBCode; use Friendica\Content\Text\BBCode;
use Friendica\Content\Text\HTML; use Friendica\Content\Text\HTML;
@ -29,6 +28,7 @@ use Friendica\Core\Session;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\Core\Worker; use Friendica\Core\Worker;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Attach; use Friendica\Model\Attach;
use Friendica\Model\Contact; use Friendica\Model\Contact;
use Friendica\Model\Conversation; use Friendica\Model\Conversation;
@ -39,7 +39,6 @@ use Friendica\Model\Term;
use Friendica\Protocol\Activity; use Friendica\Protocol\Activity;
use Friendica\Protocol\Diaspora; use Friendica\Protocol\Diaspora;
use Friendica\Protocol\Email; use Friendica\Protocol\Email;
use Friendica\Util\ACLFormatter;
use Friendica\Util\DateTimeFormat; use Friendica\Util\DateTimeFormat;
use Friendica\Util\Emailer; use Friendica\Util\Emailer;
use Friendica\Util\Security; use Friendica\Util\Security;
@ -273,8 +272,7 @@ function item_post(App $a) {
} else { } else {
// use the posted permissions // use the posted permissions
/** @var ACLFormatter $aclFormatter */ $aclFormatter = DI::aclFormatter();
$aclFormatter = BaseObject::getClass(ACLFormatter::class);
$str_group_allow = $aclFormatter->toString($_REQUEST['group_allow'] ?? ''); $str_group_allow = $aclFormatter->toString($_REQUEST['group_allow'] ?? '');
$str_contact_allow = $aclFormatter->toString($_REQUEST['contact_allow'] ?? ''); $str_contact_allow = $aclFormatter->toString($_REQUEST['contact_allow'] ?? '');
@ -506,9 +504,7 @@ function item_post(App $a) {
$objecttype = Activity\ObjectType::BOOKMARK; $objecttype = Activity\ObjectType::BOOKMARK;
} }
/** @var BBCode\Video $bbCodeVideo */ $body = DI::bbCodeVideo()->transform($body);
$bbCodeVideo = BaseObject::getClass(BBCode\Video::class);
$body = $bbCodeVideo->transform($body);
// Fold multi-line [code] sequences // Fold multi-line [code] sequences
$body = preg_replace('/\[\/code\]\s*\[code\]/ism', "\n", $body); $body = preg_replace('/\[\/code\]\s*\[code\]/ism', "\n", $body);

View file

@ -3,13 +3,12 @@
* @file mod/lockview.php * @file mod/lockview.php
*/ */
use Friendica\App; use Friendica\App;
use Friendica\BaseObject;
use Friendica\Core\Hook; use Friendica\Core\Hook;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Group; use Friendica\Model\Group;
use Friendica\Model\Item; use Friendica\Model\Item;
use Friendica\Util\ACLFormatter;
function lockview_content(App $a) function lockview_content(App $a)
{ {
@ -61,8 +60,7 @@ function lockview_content(App $a)
exit(); exit();
} }
/** @var ACLFormatter $aclFormatter */ $aclFormatter = DI::aclFormatter();
$aclFormatter = BaseObject::getClass(ACLFormatter::class);
$allowed_users = $aclFormatter->expand($item['allow_cid']); $allowed_users = $aclFormatter->expand($item['allow_cid']);
$allowed_groups = $aclFormatter->expand($item['allow_gid']); $allowed_groups = $aclFormatter->expand($item['allow_gid']);

View file

@ -5,7 +5,6 @@
*/ */
use Friendica\App; use Friendica\App;
use Friendica\BaseObject;
use Friendica\Content\Feature; use Friendica\Content\Feature;
use Friendica\Content\ForumManager; use Friendica\Content\ForumManager;
use Friendica\Content\Nav; use Friendica\Content\Nav;
@ -22,6 +21,7 @@ use Friendica\Core\Protocol;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\Core\Session; use Friendica\Core\Session;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact; use Friendica\Model\Contact;
use Friendica\Model\Group; use Friendica\Model\Group;
use Friendica\Model\Item; use Friendica\Model\Item;
@ -52,12 +52,9 @@ function network_init(App $a)
$group_id = 0; $group_id = 0;
} }
/** @var DateTimeFormat $dtFormat */
$dtFormat = BaseObject::getClass(DateTimeFormat::class);
if ($a->argc > 1) { if ($a->argc > 1) {
for ($x = 1; $x < $a->argc; $x ++) { for ($x = 1; $x < $a->argc; $x ++) {
if ($dtFormat->isYearMonth($a->argv[$x])) { if (DI::dtFormat()->isYearMonth($a->argv[$x])) {
$is_a_date_query = true; $is_a_date_query = true;
break; break;
} }
@ -465,12 +462,9 @@ function networkThreadedView(App $a, $update, $parent)
$default_permissions = []; $default_permissions = [];
/** @var DateTimeFormat $dtFormat */
$dtFormat = BaseObject::getClass(DateTimeFormat::class);
if ($a->argc > 1) { if ($a->argc > 1) {
for ($x = 1; $x < $a->argc; $x ++) { for ($x = 1; $x < $a->argc; $x ++) {
if ($dtFormat->isYearMonth($a->argv[$x])) { if (DI::dtFormat()->isYearMonth($a->argv[$x])) {
if ($datequery) { if ($datequery) {
$datequery2 = Strings::escapeHtml($a->argv[$x]); $datequery2 = Strings::escapeHtml($a->argv[$x]);
} else { } else {

View file

@ -13,6 +13,7 @@ use Friendica\Core\Protocol;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Module\Security\Login; use Friendica\Module\Security\Login;
use Friendica\Model\Introduction; use Friendica\Model\Introduction;
use Friendica\Model\Notify; use Friendica\Model\Notify;
@ -61,8 +62,7 @@ function notifications_content(App $a)
$json = (($a->argc > 1 && $a->argv[$a->argc - 1] === 'json') ? true : false); $json = (($a->argc > 1 && $a->argv[$a->argc - 1] === 'json') ? true : false);
/** @var Notify $nm */ $nm = DI::notify();
$nm = \Friendica\BaseObject::getClass(Notify::class);
$o = ''; $o = '';
// Get the nav tabs for the notification pages // Get the nav tabs for the notification pages

View file

@ -4,7 +4,6 @@
*/ */
use Friendica\App; use Friendica\App;
use Friendica\BaseObject;
use Friendica\Content\Feature; use Friendica\Content\Feature;
use Friendica\Content\Nav; use Friendica\Content\Nav;
use Friendica\Content\Pager; use Friendica\Content\Pager;
@ -18,6 +17,7 @@ use Friendica\Core\Renderer;
use Friendica\Core\Session; use Friendica\Core\Session;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact; use Friendica\Model\Contact;
use Friendica\Model\Item; use Friendica\Model\Item;
use Friendica\Model\Photo; use Friendica\Model\Photo;
@ -26,7 +26,6 @@ use Friendica\Model\User;
use Friendica\Network\Probe; use Friendica\Network\Probe;
use Friendica\Object\Image; use Friendica\Object\Image;
use Friendica\Protocol\Activity; use Friendica\Protocol\Activity;
use Friendica\Util\ACLFormatter;
use Friendica\Util\Crypto; use Friendica\Util\Crypto;
use Friendica\Util\DateTimeFormat; use Friendica\Util\DateTimeFormat;
use Friendica\Util\Images; use Friendica\Util\Images;
@ -298,8 +297,7 @@ function photos_post(App $a)
$albname = !empty($_POST['albname']) ? Strings::escapeTags(trim($_POST['albname'])) : ''; $albname = !empty($_POST['albname']) ? Strings::escapeTags(trim($_POST['albname'])) : '';
$origaname = !empty($_POST['origaname']) ? Strings::escapeTags(trim($_POST['origaname'])) : ''; $origaname = !empty($_POST['origaname']) ? Strings::escapeTags(trim($_POST['origaname'])) : '';
/** @var ACLFormatter $aclFormatter */ $aclFormatter = DI::aclFormatter();
$aclFormatter = BaseObject::getClass(ACLFormatter::class);
$str_group_allow = !empty($_POST['group_allow']) ? $aclFormatter->toString($_POST['group_allow']) : ''; $str_group_allow = !empty($_POST['group_allow']) ? $aclFormatter->toString($_POST['group_allow']) : '';
$str_contact_allow = !empty($_POST['contact_allow']) ? $aclFormatter->toString($_POST['contact_allow']) : ''; $str_contact_allow = !empty($_POST['contact_allow']) ? $aclFormatter->toString($_POST['contact_allow']) : '';
@ -640,8 +638,7 @@ function photos_post(App $a)
$group_deny = $_REQUEST['group_deny'] ?? []; $group_deny = $_REQUEST['group_deny'] ?? [];
$contact_deny = $_REQUEST['contact_deny'] ?? []; $contact_deny = $_REQUEST['contact_deny'] ?? [];
/** @var ACLFormatter $aclFormatter */ $aclFormatter = DI::aclFormatter();
$aclFormatter = BaseObject::getClass(ACLFormatter::class);
$str_group_allow = $aclFormatter->toString(is_array($group_allow) ? $group_allow : explode(',', $group_allow)); $str_group_allow = $aclFormatter->toString(is_array($group_allow) ? $group_allow : explode(',', $group_allow));
$str_contact_allow = $aclFormatter->toString(is_array($contact_allow) ? $contact_allow : explode(',', $contact_allow)); $str_contact_allow = $aclFormatter->toString(is_array($contact_allow) ? $contact_allow : explode(',', $contact_allow));
@ -1442,8 +1439,7 @@ function photos_content(App $a)
$template = $tpl; $template = $tpl;
$sparkle = ''; $sparkle = '';
/** @var Activity $activity */ $activity = DI::activity();
$activity = BaseObject::getClass(Activity::class);
if (($activity->match($item['verb'], Activity::LIKE) || if (($activity->match($item['verb'], Activity::LIKE) ||
$activity->match($item['verb'], Activity::DISLIKE)) && $activity->match($item['verb'], Activity::DISLIKE)) &&

View file

@ -5,7 +5,6 @@
use Friendica\App; use Friendica\App;
use Friendica\BaseModule; use Friendica\BaseModule;
use Friendica\BaseObject;
use Friendica\Content\Feature; use Friendica\Content\Feature;
use Friendica\Content\Nav; use Friendica\Content\Nav;
use Friendica\Core\ACL; use Friendica\Core\ACL;
@ -20,14 +19,13 @@ use Friendica\Core\System;
use Friendica\Core\Theme; use Friendica\Core\Theme;
use Friendica\Core\Worker; use Friendica\Core\Worker;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact; use Friendica\Model\Contact;
use Friendica\Model\GContact; use Friendica\Model\GContact;
use Friendica\Model\Group; use Friendica\Model\Group;
use Friendica\Model\User; use Friendica\Model\User;
use Friendica\Module\Security\Login; use Friendica\Module\Security\Login;
use Friendica\Protocol\Email; use Friendica\Protocol\Email;
use Friendica\Util\ACLFormatter;
use Friendica\Util\Network;
use Friendica\Util\Strings; use Friendica\Util\Strings;
use Friendica\Util\Temporal; use Friendica\Util\Temporal;
use Friendica\Worker\Delivery; use Friendica\Worker\Delivery;
@ -564,8 +562,7 @@ function settings_post(App $a)
date_default_timezone_set($timezone); date_default_timezone_set($timezone);
} }
/** @var ACLFormatter $aclFormatter */ $aclFormatter = DI::aclFormatter();
$aclFormatter = BaseObject::getClass(ACLFormatter::class);
$str_group_allow = !empty($_POST['group_allow']) ? $aclFormatter->toString($_POST['group_allow']) : ''; $str_group_allow = !empty($_POST['group_allow']) ? $aclFormatter->toString($_POST['group_allow']) : '';
$str_contact_allow = !empty($_POST['contact_allow']) ? $aclFormatter->toString($_POST['contact_allow']) : ''; $str_contact_allow = !empty($_POST['contact_allow']) ? $aclFormatter->toString($_POST['contact_allow']) : '';

View file

@ -3,7 +3,7 @@
namespace Friendica\App; namespace Friendica\App;
use Friendica\App; use Friendica\App;
use Friendica\BaseObject; use Friendica\BaseModule;
use Friendica\Core; use Friendica\Core;
use Friendica\LegacyModule; use Friendica\LegacyModule;
use Friendica\Module\Home; use Friendica\Module\Home;
@ -59,7 +59,7 @@ class Module
private $module; private $module;
/** /**
* @var BaseObject The module class * @var BaseModule The module class
*/ */
private $module_class; private $module_class;

View file

@ -14,7 +14,7 @@ use Friendica\Core\Logger;
* *
* @author Hypolite Petovan <hypolite@mrpetovan.com> * @author Hypolite Petovan <hypolite@mrpetovan.com>
*/ */
abstract class BaseModule extends BaseObject abstract class BaseModule
{ {
/** /**
* @brief Initialization method common to both content() and post() * @brief Initialization method common to both content() and post()

View file

@ -1,58 +0,0 @@
<?php
/**
* @file src/BaseObject.php
*/
namespace Friendica;
require_once __DIR__ . '/../boot.php';
use Dice\Dice;
use Friendica\Network\HTTPException\InternalServerErrorException;
/**
* Basic object
*
* Contains what is useful to any object
*
* Act's like a global registry for classes
*/
class BaseObject
{
/**
* @var Dice The Dependency Injection library
*/
private static $dice;
/**
* Set's the dependency injection library for a global usage
*
* @param Dice $dice The dependency injection library
*/
public static function setDependencyInjection(Dice $dice)
{
self::$dice = $dice;
DI::init($dice);
}
/**
* Returns the initialized class based on it's name
*
* @param string $name The name of the class
*
* @return object The initialized name
*
* @throws InternalServerErrorException
*/
public static function getClass(string $name)
{
if (empty(self::$dice)) {
throw new InternalServerErrorException('DICE isn\'t initialized.');
}
if (class_exists($name) || interface_exists($name)) {
return self::$dice->create($name);
} else {
throw new InternalServerErrorException('Class \'' . $name . '\' isn\'t valid.');
}
}
}

View file

@ -8,7 +8,6 @@ namespace Friendica\Content\Text;
use DOMDocument; use DOMDocument;
use DOMXPath; use DOMXPath;
use Exception; use Exception;
use Friendica\BaseObject;
use Friendica\Content\OEmbed; use Friendica\Content\OEmbed;
use Friendica\Content\Smilies; use Friendica\Content\Smilies;
use Friendica\Core\Cache; use Friendica\Core\Cache;
@ -34,7 +33,7 @@ use Friendica\Util\Proxy as ProxyUtils;
use Friendica\Util\Strings; use Friendica\Util\Strings;
use Friendica\Util\XML; use Friendica\Util\XML;
class BBCode extends BaseObject class BBCode
{ {
/** /**
* @brief Fetches attachment data that were generated the old way * @brief Fetches attachment data that were generated the old way

View file

@ -6,7 +6,6 @@
namespace Friendica\Content\Text; namespace Friendica\Content\Text;
use Friendica\BaseObject;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\DI; use Friendica\DI;
use Friendica\Model\Contact; use Friendica\Model\Contact;
@ -16,7 +15,7 @@ use Friendica\Model\Contact;
* *
* @author Hypolite Petovan <hypolite@mrpetovan.com> * @author Hypolite Petovan <hypolite@mrpetovan.com>
*/ */
class Markdown extends BaseObject class Markdown
{ {
/** /**
* Converts a Markdown string into HTML. The hardwrap parameter maximizes * Converts a Markdown string into HTML. The hardwrap parameter maximizes

View file

@ -7,7 +7,6 @@
namespace Friendica\Core; namespace Friendica\Core;
use Friendica\App\Page; use Friendica\App\Page;
use Friendica\BaseObject;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI; use Friendica\DI;
use Friendica\Model\Contact; use Friendica\Model\Contact;
@ -18,7 +17,7 @@ use Friendica\Model\Group;
* *
* @author Hypolite Petovan <hypolite@mrpetovan.com> * @author Hypolite Petovan <hypolite@mrpetovan.com>
*/ */
class ACL extends BaseObject class ACL
{ {
/** /**
* Returns a select input tag with all the contact of the local user * Returns a select input tag with all the contact of the local user

View file

@ -5,7 +5,6 @@
namespace Friendica\Core; namespace Friendica\Core;
use Friendica\BaseObject;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI; use Friendica\DI;
use Friendica\Util\Strings; use Friendica\Util\Strings;
@ -13,7 +12,7 @@ use Friendica\Util\Strings;
/** /**
* Some functions to handle addons * Some functions to handle addons
*/ */
class Addon extends BaseObject class Addon
{ {
/** /**
* The addon sub-directory * The addon sub-directory

View file

@ -4,14 +4,13 @@
*/ */
namespace Friendica\Core; namespace Friendica\Core;
use Friendica\BaseObject;
use Friendica\Core\Cache\Cache as CacheClass; use Friendica\Core\Cache\Cache as CacheClass;
use Friendica\Core\Cache\ICache; use Friendica\DI;
/** /**
* @brief Class for storing data for a short time * @brief Class for storing data for a short time
*/ */
class Cache extends BaseObject class Cache
{ {
/** @deprecated Use CacheClass::MONTH */ /** @deprecated Use CacheClass::MONTH */
const MONTH = CacheClass::MONTH; const MONTH = CacheClass::MONTH;
@ -42,7 +41,7 @@ class Cache extends BaseObject
*/ */
public static function getAllKeys($prefix = null) public static function getAllKeys($prefix = null)
{ {
return self::getClass(ICache::class)->getAllKeys($prefix); return DI::cache()->getAllKeys($prefix);
} }
/** /**
@ -55,7 +54,7 @@ class Cache extends BaseObject
*/ */
public static function get($key) public static function get($key)
{ {
return self::getClass(ICache::class)->get($key); return DI::cache()->get($key);
} }
/** /**
@ -72,7 +71,7 @@ class Cache extends BaseObject
*/ */
public static function set($key, $value, $duration = CacheClass::MONTH) public static function set($key, $value, $duration = CacheClass::MONTH)
{ {
return self::getClass(ICache::class)->set($key, $value, $duration); return DI::cache()->set($key, $value, $duration);
} }
/** /**
@ -85,7 +84,7 @@ class Cache extends BaseObject
*/ */
public static function delete($key) public static function delete($key)
{ {
return self::getClass(ICache::class)->delete($key); return DI::cache()->delete($key);
} }
/** /**
@ -98,6 +97,6 @@ class Cache extends BaseObject
*/ */
public static function clear($outdated = true) public static function clear($outdated = true)
{ {
return self::getClass(ICache::class)->clear($outdated); return DI::cache()->clear($outdated);
} }
} }

View file

@ -8,8 +8,7 @@
*/ */
namespace Friendica\Core; namespace Friendica\Core;
use Friendica\BaseObject; use Friendica\DI;
use Friendica\Core\Config\Configuration;
/** /**
* @brief Arbitrary system configuration storage * @brief Arbitrary system configuration storage
@ -18,7 +17,7 @@ use Friendica\Core\Config\Configuration;
* If we ever would decide to return exactly the variable type as entered, * If we ever would decide to return exactly the variable type as entered,
* we will have fun with the additional features. :-) * we will have fun with the additional features. :-)
*/ */
class Config extends BaseObject class Config
{ {
/** /**
* @brief Loads all configuration values of family into a cached storage. * @brief Loads all configuration values of family into a cached storage.
@ -29,7 +28,7 @@ class Config extends BaseObject
*/ */
public static function load($cat = "config") public static function load($cat = "config")
{ {
self::getClass(Configuration::class)->load($cat); DI::config()->load($cat);
} }
/** /**
@ -45,7 +44,7 @@ class Config extends BaseObject
*/ */
public static function get($cat, $key, $default_value = null, $refresh = false) public static function get($cat, $key, $default_value = null, $refresh = false)
{ {
return self::getClass(Configuration::class)->get($cat, $key, $default_value, $refresh); return DI::config()->get($cat, $key, $default_value, $refresh);
} }
/** /**
@ -63,7 +62,7 @@ class Config extends BaseObject
*/ */
public static function set($cat, $key, $value) public static function set($cat, $key, $value)
{ {
return self::getClass(Configuration::class)->set($cat, $key, $value); return DI::config()->set($cat, $key, $value);
} }
/** /**
@ -76,6 +75,6 @@ class Config extends BaseObject
*/ */
public static function delete($cat, $key) public static function delete($cat, $key)
{ {
return self::getClass(Configuration::class)->delete($cat, $key); return DI::config()->delete($cat, $key);
} }
} }

View file

@ -146,7 +146,7 @@ HELP;
$className = $this->subConsoles[$command]; $className = $this->subConsoles[$command];
Friendica\BaseObject::setDependencyInjection($this->dice); Friendica\DI::init($this->dice);
/** @var Console $subconsole */ /** @var Console $subconsole */
$subconsole = $this->dice->create($className, [$subargs]); $subconsole = $this->dice->create($className, [$subargs]);

View file

@ -5,7 +5,6 @@
namespace Friendica\Core; namespace Friendica\Core;
use Friendica\App; use Friendica\App;
use Friendica\BaseObject;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI; use Friendica\DI;
use Friendica\Util\Strings; use Friendica\Util\Strings;
@ -13,7 +12,7 @@ use Friendica\Util\Strings;
/** /**
* Some functions to handle hooks * Some functions to handle hooks
*/ */
class Hook extends BaseObject class Hook
{ {
/** /**
* Array of registered hooks * Array of registered hooks

View file

@ -4,14 +4,14 @@
*/ */
namespace Friendica\Core; namespace Friendica\Core;
use Friendica\BaseObject;
use Friendica\Core\L10n\L10n as L10nClass; use Friendica\Core\L10n\L10n as L10nClass;
use Friendica\DI;
/** /**
* Provide Language, Translation, and Localization functions to the application * Provide Language, Translation, and Localization functions to the application
* Localization can be referred to by the numeronym L10N (as in: "L", followed by ten more letters, and then "N"). * Localization can be referred to by the numeronym L10N (as in: "L", followed by ten more letters, and then "N").
*/ */
class L10n extends BaseObject class L10n
{ {
/** /**
* Returns the current language code * Returns the current language code
@ -20,7 +20,7 @@ class L10n extends BaseObject
*/ */
public static function getCurrentLang() public static function getCurrentLang()
{ {
return self::getClass(L10nClass::class)->getCurrentLang(); return DI::l10n()->getCurrentLang();
} }
/** /**
@ -32,7 +32,7 @@ class L10n extends BaseObject
*/ */
public static function withLang(string $lang) public static function withLang(string $lang)
{ {
return self::getClass(L10nClass::class)->withLang($lang); DI::l10n()->withLang($lang);
} }
/** /**
@ -54,7 +54,7 @@ class L10n extends BaseObject
*/ */
public static function t($s, ...$vars) public static function t($s, ...$vars)
{ {
return self::getClass(L10nClass::class)->t($s, ...$vars); return DI::l10n()->t($s, ...$vars);
} }
/** /**
@ -79,7 +79,7 @@ class L10n extends BaseObject
*/ */
public static function tt(string $singular, string $plural, int $count) public static function tt(string $singular, string $plural, int $count)
{ {
return self::getClass(L10nClass::class)->tt($singular, $plural, $count); return DI::l10n()->tt($singular, $plural, $count);
} }
/** /**
@ -107,7 +107,7 @@ class L10n extends BaseObject
*/ */
public static function getDay($s) public static function getDay($s)
{ {
return self::getClass(L10nClass::class)->getDay($s); return DI::l10n()->getDay($s);
} }
/** /**
@ -119,7 +119,7 @@ class L10n extends BaseObject
*/ */
public static function getDayShort($s) public static function getDayShort($s)
{ {
return self::getClass(L10nClass::class)->getDayShort($s); return DI::l10n()->getDayShort($s);
} }
/** /**
@ -131,6 +131,6 @@ class L10n extends BaseObject
*/ */
public static function getPokeVerbs() public static function getPokeVerbs()
{ {
return self::getClass(L10nClass::class)->getPokeVerbs(); return DI::l10n()->getPokeVerbs();
} }
} }

View file

@ -7,14 +7,13 @@
namespace Friendica\Core; namespace Friendica\Core;
use Friendica\BaseObject;
use Friendica\Core\Cache\Cache; use Friendica\Core\Cache\Cache;
use Friendica\Core\Lock\ILock; use Friendica\DI;
/** /**
* This class contain Functions for preventing parallel execution of functions * This class contain Functions for preventing parallel execution of functions
*/ */
class Lock extends BaseObject class Lock
{ {
/** /**
* @brief Acquires a lock for a given name * @brief Acquires a lock for a given name
@ -28,7 +27,7 @@ class Lock extends BaseObject
*/ */
public static function acquire($key, $timeout = 120, $ttl = Cache::FIVE_MINUTES) public static function acquire($key, $timeout = 120, $ttl = Cache::FIVE_MINUTES)
{ {
return self::getClass(ILock::class)->acquireLock($key, $timeout, $ttl); return DI::lock()->acquireLock($key, $timeout, $ttl);
} }
/** /**
@ -37,12 +36,12 @@ class Lock extends BaseObject
* @param string $key Name of the lock * @param string $key Name of the lock
* @param bool $override Overrides the lock to get releases * @param bool $override Overrides the lock to get releases
* *
* @return void * @return bool
* @throws \Exception * @throws \Exception
*/ */
public static function release($key, $override = false) public static function release($key, $override = false)
{ {
return self::getClass(ILock::class)->releaseLock($key, $override); return DI::lock()->releaseLock($key, $override);
} }
/** /**
@ -52,6 +51,6 @@ class Lock extends BaseObject
*/ */
public static function releaseAll() public static function releaseAll()
{ {
self::getClass(ILock::class)->releaseAll(); DI::lock()->releaseAll();
} }
} }

View file

@ -4,7 +4,7 @@
*/ */
namespace Friendica\Core; namespace Friendica\Core;
use Friendica\BaseObject; use Friendica\DI;
use Friendica\Util\Logger\WorkerLogger; use Friendica\Util\Logger\WorkerLogger;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
use Psr\Log\LogLevel; use Psr\Log\LogLevel;
@ -12,7 +12,7 @@ use Psr\Log\LogLevel;
/** /**
* @brief Logger functions * @brief Logger functions
*/ */
class Logger extends BaseObject class Logger
{ {
/** /**
* @see Logger::error() * @see Logger::error()
@ -66,6 +66,18 @@ class Logger extends BaseObject
self::DATA => 'Data', self::DATA => 'Data',
]; ];
/**
* @return LoggerInterface
*/
private static function getWorker()
{
if (self::$type === self::TYPE_LOGGER) {
return DI::logger();
} else {
return DI::workerLogger();
}
}
/** /**
* Enable additional logging for worker usage * Enable additional logging for worker usage
* *
@ -76,7 +88,7 @@ class Logger extends BaseObject
public static function enableWorker(string $functionName) public static function enableWorker(string $functionName)
{ {
self::$type = self::TYPE_WORKER; self::$type = self::TYPE_WORKER;
self::getClass(self::$type)->setFunctionName($functionName); self::getWorker()->setFunctionName($functionName);
} }
/** /**
@ -100,7 +112,7 @@ class Logger extends BaseObject
*/ */
public static function emergency($message, $context = []) public static function emergency($message, $context = [])
{ {
self::getClass(self::$type)->emergency($message, $context); self::getWorker()->emergency($message, $context);
} }
/** /**
@ -118,7 +130,7 @@ class Logger extends BaseObject
*/ */
public static function alert($message, $context = []) public static function alert($message, $context = [])
{ {
self::getClass(self::$type)->alert($message, $context); self::getWorker()->alert($message, $context);
} }
/** /**
@ -135,7 +147,7 @@ class Logger extends BaseObject
*/ */
public static function critical($message, $context = []) public static function critical($message, $context = [])
{ {
self::getClass(self::$type)->critical($message, $context); self::getWorker()->critical($message, $context);
} }
/** /**
@ -151,7 +163,7 @@ class Logger extends BaseObject
*/ */
public static function error($message, $context = []) public static function error($message, $context = [])
{ {
self::getClass(self::$type)->error($message, $context); self::getWorker()->error($message, $context);
} }
/** /**
@ -169,7 +181,7 @@ class Logger extends BaseObject
*/ */
public static function warning($message, $context = []) public static function warning($message, $context = [])
{ {
self::getClass(self::$type)->warning($message, $context); self::getWorker()->warning($message, $context);
} }
/** /**
@ -184,7 +196,7 @@ class Logger extends BaseObject
*/ */
public static function notice($message, $context = []) public static function notice($message, $context = [])
{ {
self::getClass(self::$type)->notice($message, $context); self::getWorker()->notice($message, $context);
} }
/** /**
@ -201,7 +213,7 @@ class Logger extends BaseObject
*/ */
public static function info($message, $context = []) public static function info($message, $context = [])
{ {
self::getClass(self::$type)->info($message, $context); self::getWorker()->info($message, $context);
} }
/** /**
@ -216,7 +228,7 @@ class Logger extends BaseObject
*/ */
public static function debug($message, $context = []) public static function debug($message, $context = [])
{ {
self::getClass(self::$type)->debug($message, $context); self::getWorker()->debug($message, $context);
} }
/** /**
@ -230,7 +242,7 @@ class Logger extends BaseObject
*/ */
public static function log($msg, $level = LogLevel::INFO) public static function log($msg, $level = LogLevel::INFO)
{ {
self::getClass(self::$type)->log($level, $msg); self::getWorker()->log($level, $msg);
} }
/** /**
@ -245,6 +257,6 @@ class Logger extends BaseObject
*/ */
public static function devLog($msg, $level = LogLevel::DEBUG) public static function devLog($msg, $level = LogLevel::DEBUG)
{ {
self::getClass('$devLogger')->log($level, $msg); DI::devLogger()->log($level, $msg);
} }
} }

View file

@ -8,8 +8,7 @@
*/ */
namespace Friendica\Core; namespace Friendica\Core;
use Friendica\BaseObject; use Friendica\DI;
use Friendica\Core\Config\PConfiguration;
/** /**
* @brief Management of user configuration storage * @brief Management of user configuration storage
@ -18,7 +17,7 @@ use Friendica\Core\Config\PConfiguration;
* The PConfig::get() functions return boolean false for keys that are unset, * The PConfig::get() functions return boolean false for keys that are unset,
* and this could lead to subtle bugs. * and this could lead to subtle bugs.
*/ */
class PConfig extends BaseObject class PConfig
{ {
/** /**
* @brief Loads all configuration values of a user's config family into a cached storage. * @brief Loads all configuration values of a user's config family into a cached storage.
@ -30,7 +29,7 @@ class PConfig extends BaseObject
*/ */
public static function load(int $uid, string $cat) public static function load(int $uid, string $cat)
{ {
self::getClass(PConfiguration::class)->load($uid, $cat); DI::pConfig()->load($uid, $cat);
} }
/** /**
@ -47,7 +46,7 @@ class PConfig extends BaseObject
*/ */
public static function get(int $uid, string $cat, string $key, $default_value = null, bool $refresh = false) public static function get(int $uid, string $cat, string $key, $default_value = null, bool $refresh = false)
{ {
return self::getClass(PConfiguration::class)->get($uid, $cat, $key, $default_value, $refresh); return DI::pConfig()->get($uid, $cat, $key, $default_value, $refresh);
} }
/** /**
@ -62,7 +61,7 @@ class PConfig extends BaseObject
*/ */
public static function set(int $uid, string $cat, string $key, $value) public static function set(int $uid, string $cat, string $key, $value)
{ {
return self::getClass(PConfiguration::class)->set($uid, $cat, $key, $value); return DI::pConfig()->set($uid, $cat, $key, $value);
} }
/** /**
@ -76,6 +75,6 @@ class PConfig extends BaseObject
*/ */
public static function delete(int $uid, string $cat, string $key) public static function delete(int $uid, string $cat, string $key)
{ {
return self::getClass(PConfiguration::class)->delete($uid, $cat, $key); return DI::pConfig()->delete($uid, $cat, $key);
} }
} }

View file

@ -6,7 +6,6 @@
namespace Friendica\Core; namespace Friendica\Core;
use Exception; use Exception;
use Friendica\BaseObject;
use Friendica\DI; use Friendica\DI;
use Friendica\Render\FriendicaSmarty; use Friendica\Render\FriendicaSmarty;
use Friendica\Render\ITemplateEngine; use Friendica\Render\ITemplateEngine;
@ -14,7 +13,7 @@ use Friendica\Render\ITemplateEngine;
/** /**
* @brief This class handles Renderer related functions. * @brief This class handles Renderer related functions.
*/ */
class Renderer extends BaseObject class Renderer
{ {
/** /**
* @brief An array of registered template engines ('name'=>'class name') * @brief An array of registered template engines ('name'=>'class name')

View file

@ -2,7 +2,6 @@
namespace Friendica\Core; namespace Friendica\Core;
use Friendica\BaseObject;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI; use Friendica\DI;
use Friendica\Model\Contact; use Friendica\Model\Contact;
@ -21,7 +20,7 @@ use Friendica\Util\Strings;
* - Search in the local directory * - Search in the local directory
* - Search in the global directory * - Search in the global directory
*/ */
class Search extends BaseObject class Search
{ {
const DEFAULT_DIRECTORY = 'https://dir.friendica.social'; const DEFAULT_DIRECTORY = 'https://dir.friendica.social';

View file

@ -5,9 +5,8 @@
*/ */
namespace Friendica\Core; namespace Friendica\Core;
use Friendica\BaseObject;
use Friendica\Core\Session\ISession;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact; use Friendica\Model\Contact;
use Friendica\Util\Strings; use Friendica\Util\Strings;
@ -16,39 +15,39 @@ use Friendica\Util\Strings;
* *
* @author Hypolite Petovan <hypolite@mrpetovan.com> * @author Hypolite Petovan <hypolite@mrpetovan.com>
*/ */
class Session extends BaseObject class Session
{ {
public static $exists = false; public static $exists = false;
public static $expire = 180000; public static $expire = 180000;
public static function exists($name) public static function exists($name)
{ {
return self::getClass(ISession::class)->exists($name); return DI::session()->exists($name);
} }
public static function get($name, $defaults = null) public static function get($name, $defaults = null)
{ {
return self::getClass(ISession::class)->get($name, $defaults); return DI::session()->get($name, $defaults);
} }
public static function set($name, $value) public static function set($name, $value)
{ {
self::getClass(ISession::class)->set($name, $value); DI::session()->set($name, $value);
} }
public static function setMultiple(array $values) public static function setMultiple(array $values)
{ {
self::getClass(ISession::class)->setMultiple($values); DI::session()->setMultiple($values);
} }
public static function remove($name) public static function remove($name)
{ {
self::getClass(ISession::class)->remove($name); DI::session()->remove($name);
} }
public static function clear() public static function clear()
{ {
self::getClass(ISession::class)->clear(); DI::session()->clear();
} }
/** /**
@ -59,8 +58,7 @@ class Session extends BaseObject
*/ */
public static function getRemoteContactID($uid) public static function getRemoteContactID($uid)
{ {
/** @var ISession $session */ $session = DI::session();
$session = self::getClass(ISession::class);
if (empty($session->get('remote')[$uid])) { if (empty($session->get('remote')[$uid])) {
return false; return false;
@ -77,8 +75,7 @@ class Session extends BaseObject
*/ */
public static function getUserIDForVisitorContactID($cid) public static function getUserIDForVisitorContactID($cid)
{ {
/** @var ISession $session */ $session = DI::session();
$session = self::getClass(ISession::class);
if (empty($session->get('remote'))) { if (empty($session->get('remote'))) {
return false; return false;
@ -94,8 +91,7 @@ class Session extends BaseObject
*/ */
public static function setVisitorsContacts() public static function setVisitorsContacts()
{ {
/** @var ISession $session */ $session = DI::session();
$session = self::getClass(ISession::class);
$session->set('remote', []); $session->set('remote', []);
@ -117,8 +113,7 @@ class Session extends BaseObject
*/ */
public static function isAuthenticated() public static function isAuthenticated()
{ {
/** @var ISession $session */ $session = DI::session();
$session = self::getClass(ISession::class);
return $session->get('authenticated', false); return $session->get('authenticated', false);
} }

View file

@ -4,8 +4,6 @@
*/ */
namespace Friendica\Core; namespace Friendica\Core;
use Friendica\App\BaseURL;
use Friendica\BaseObject;
use Friendica\DI; use Friendica\DI;
use Friendica\Network\HTTPException\InternalServerErrorException; use Friendica\Network\HTTPException\InternalServerErrorException;
use Friendica\Util\XML; use Friendica\Util\XML;
@ -20,18 +18,17 @@ use Friendica\Util\XML;
/** /**
* @brief System methods * @brief System methods
*/ */
class System extends BaseObject class System
{ {
/** /**
* @brief Retrieves the Friendica instance base URL * @brief Retrieves the Friendica instance base URL
* *
* @param bool $ssl Whether to append http or https under BaseURL::SSL_POLICY_SELFSIGN * @param bool $ssl Whether to append http or https under BaseURL::SSL_POLICY_SELFSIGN
* @return string Friendica server base URL * @return string Friendica server base URL
* @throws InternalServerErrorException
*/ */
public static function baseUrl($ssl = false) public static function baseUrl($ssl = false)
{ {
return self::getClass(BaseURL::class)->get($ssl); return DI::baseUrl()->get($ssl);
} }
/** /**

View file

@ -6,7 +6,6 @@
namespace Friendica\Core; namespace Friendica\Core;
use Friendica\BaseObject;
use Friendica\DI; use Friendica\DI;
use Friendica\Model\Profile; use Friendica\Model\Profile;
use Friendica\Util\Strings; use Friendica\Util\Strings;

View file

@ -4,7 +4,6 @@
*/ */
namespace Friendica\Core; namespace Friendica\Core;
use Friendica\BaseObject;
use Friendica\Core; use Friendica\Core;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI; use Friendica\DI;

View file

@ -3,6 +3,22 @@
namespace Friendica; namespace Friendica;
use Dice\Dice; use Dice\Dice;
use Friendica\Core\Cache\ICache;
use Friendica\Core\Config\Configuration;
use Friendica\Core\Config\PConfiguration;
use Friendica\Core\L10n\L10n;
use Friendica\Core\Lock\ILock;
use Friendica\Core\Session\ISession;
use Friendica\Database\Database;
use Friendica\Model\Notify;
use Friendica\Protocol\Activity;
use Friendica\Util\ACLFormatter;
use Friendica\Content\Item as ContentItem;
use Friendica\Content\Text\BBCode\Video as BBCodeVideo;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\FileSystem;
use Friendica\Util\Logger\WorkerLogger;
use Psr\Log\LoggerInterface;
/** /**
* This class is capable of getting all dynamic created classes * This class is capable of getting all dynamic created classes
@ -10,6 +26,31 @@ use Dice\Dice;
* There has to be a "method" phpDoc for each new class, containing result class for a proper matching * There has to be a "method" phpDoc for each new class, containing result class for a proper matching
* *
* @method static App app() * @method static App app()
* @method static ACLFormatter aclFormatter()
* @method static Notify notify()
* @method static Activity activity()
* @method static ContentItem contentItem()
* @method static BBCodeVideo bbCodeVideo()
* @method static DateTimeFormat dtFormat()
* @method static ICache cache()
* @method static Configuration config()
* @method static PConfiguration pConfig()
* @method static ILock lock()
* @method static L10n l10n()
* @method static LoggerInterface logger()
* @method static LoggerInterface devLogger()
* @method static LoggerInterface workerLogger()
* @method static ISession session()
* @method static App\Authentication auth()
* @method static App\Arguments args()
* @method static App\BaseURL baseUrl()
* @method static App\Mode mode()
* @method static App\Module module()
* @method static App\Page page()
* @method static App\Router router()
* @method static Database dba()
* @method static FileSystem fs()
*
*/ */
class DI class DI
{ {
@ -26,6 +67,54 @@ class DI
switch ($name) { switch ($name) {
case 'app': case 'app':
return self::$dice->create(App::class, $arguments); return self::$dice->create(App::class, $arguments);
case 'aclFormatter':
return self::$dice->create(ACLFormatter::class, $arguments);
case 'auth':
return self::$dice->create(App\Authentication::class, $arguments);
case 'args':
return self::$dice->create(App\Arguments::class, $arguments);
case 'baseUrl':
return self::$dice->create(App\BaseURL::class, $arguments);
case 'mode':
return self::$dice->create(App\Mode::class, $arguments);
case 'module':
return self::$dice->create(App\Module::class, $arguments);
case 'page':
return self::$dice->create(App\Page::class, $arguments);
case 'router':
return self::$dice->create(App\Router::class, $arguments);
case 'notify':
return self::$dice->create(Notify::class, $arguments);
case 'activity':
return self::$dice->create(Activity::class, $arguments);
case 'contentItem':
return self::$dice->create(ContentItem::class, $arguments);
case 'bbCodeVideo':
return self::$dice->create(BBCodeVideo::class, $arguments);
case 'dtFormat':
return self::$dice->create(DateTimeFormat::class, $arguments);
case 'cache':
return self::$dice->create(ICache::class, $arguments);
case 'config':
return self::$dice->create(Configuration::class, $arguments);
case 'pConfig':
return self::$dice->create(PConfiguration::class, $arguments);
case 'lock':
return self::$dice->create(ILock::class, $arguments);
case 'l10n':
return self::$dice->create(L10n::class, $arguments);
case 'logger':
return self::$dice->create(LoggerInterface::class, $arguments);
case 'devLogger':
return self::$dice->create('$devLogger', $arguments);
case 'workerLogger':
return self::$dice->create(WorkerLogger::class, $arguments);
case 'session':
return self::$dice->create(ISession::class, $arguments);
case 'dba':
return self::$dice->create(Database::class, $arguments);
case 'fs':
return self::$dice->create(FileSystem::class, $arguments);
default: default:
return null; return null;
} }

View file

@ -2,7 +2,7 @@
namespace Friendica\Database; namespace Friendica\Database;
use Friendica\BaseObject; use Friendica\DI;
use mysqli; use mysqli;
use mysqli_result; use mysqli_result;
use mysqli_stmt; use mysqli_stmt;
@ -14,7 +14,7 @@ use PDOStatement;
* *
* This class is for the low level database stuff that does driver specific things. * This class is for the low level database stuff that does driver specific things.
*/ */
class DBA extends BaseObject class DBA
{ {
/** /**
* Lowest possible date value * Lowest possible date value
@ -27,7 +27,7 @@ class DBA extends BaseObject
public static function connect() public static function connect()
{ {
return self::getClass(Database::class)->connect(); return DI::dba()->connect();
} }
/** /**
@ -35,7 +35,7 @@ class DBA extends BaseObject
*/ */
public static function disconnect() public static function disconnect()
{ {
self::getClass(Database::class)->disconnect(); DI::dba()->disconnect();
} }
/** /**
@ -43,7 +43,7 @@ class DBA extends BaseObject
*/ */
public static function reconnect() public static function reconnect()
{ {
return self::getClass(Database::class)->reconnect(); return DI::dba()->reconnect();
} }
/** /**
@ -52,7 +52,7 @@ class DBA extends BaseObject
*/ */
public static function getConnection() public static function getConnection()
{ {
return self::getClass(Database::class)->getConnection(); return DI::dba()->getConnection();
} }
/** /**
@ -65,7 +65,7 @@ class DBA extends BaseObject
*/ */
public static function serverInfo() public static function serverInfo()
{ {
return self::getClass(Database::class)->serverInfo(); return DI::dba()->serverInfo();
} }
/** /**
@ -76,17 +76,17 @@ class DBA extends BaseObject
*/ */
public static function databaseName() public static function databaseName()
{ {
return self::getClass(Database::class)->databaseName(); return DI::dba()->databaseName();
} }
public static function escape($str) public static function escape($str)
{ {
return self::getClass(Database::class)->escape($str); return DI::dba()->escape($str);
} }
public static function connected() public static function connected()
{ {
return self::getClass(Database::class)->connected(); return DI::dba()->connected();
} }
/** /**
@ -102,7 +102,7 @@ class DBA extends BaseObject
*/ */
public static function anyValueFallback($sql) public static function anyValueFallback($sql)
{ {
return self::getClass(Database::class)->anyValueFallback($sql); return DI::dba()->anyValueFallback($sql);
} }
/** /**
@ -158,7 +158,7 @@ class DBA extends BaseObject
{ {
$params = self::getParam(func_get_args()); $params = self::getParam(func_get_args());
return self::getClass(Database::class)->p($sql, $params); return DI::dba()->p($sql, $params);
} }
/** /**
@ -174,7 +174,7 @@ class DBA extends BaseObject
$params = self::getParam(func_get_args()); $params = self::getParam(func_get_args());
return self::getClass(Database::class)->e($sql, $params); return DI::dba()->e($sql, $params);
} }
/** /**
@ -188,7 +188,7 @@ class DBA extends BaseObject
*/ */
public static function exists($table, $condition) public static function exists($table, $condition)
{ {
return self::getClass(Database::class)->exists($table, $condition); return DI::dba()->exists($table, $condition);
} }
/** /**
@ -205,7 +205,7 @@ class DBA extends BaseObject
{ {
$params = self::getParam(func_get_args()); $params = self::getParam(func_get_args());
return self::getClass(Database::class)->fetchFirst($sql, $params); return DI::dba()->fetchFirst($sql, $params);
} }
/** /**
@ -215,7 +215,7 @@ class DBA extends BaseObject
*/ */
public static function affectedRows() public static function affectedRows()
{ {
return self::getClass(Database::class)->affectedRows(); return DI::dba()->affectedRows();
} }
/** /**
@ -226,7 +226,7 @@ class DBA extends BaseObject
*/ */
public static function columnCount($stmt) public static function columnCount($stmt)
{ {
return self::getClass(Database::class)->columnCount($stmt); return DI::dba()->columnCount($stmt);
} }
/** /**
* @brief Returns the number of rows of a statement * @brief Returns the number of rows of a statement
@ -236,7 +236,7 @@ class DBA extends BaseObject
*/ */
public static function numRows($stmt) public static function numRows($stmt)
{ {
return self::getClass(Database::class)->numRows($stmt); return DI::dba()->numRows($stmt);
} }
/** /**
@ -247,7 +247,7 @@ class DBA extends BaseObject
*/ */
public static function fetch($stmt) public static function fetch($stmt)
{ {
return self::getClass(Database::class)->fetch($stmt); return DI::dba()->fetch($stmt);
} }
/** /**
@ -262,7 +262,7 @@ class DBA extends BaseObject
*/ */
public static function insert($table, $param, $on_duplicate_update = false) public static function insert($table, $param, $on_duplicate_update = false)
{ {
return self::getClass(Database::class)->insert($table, $param, $on_duplicate_update); return DI::dba()->insert($table, $param, $on_duplicate_update);
} }
/** /**
@ -272,7 +272,7 @@ class DBA extends BaseObject
*/ */
public static function lastInsertId() public static function lastInsertId()
{ {
return self::getClass(Database::class)->lastInsertId(); return DI::dba()->lastInsertId();
} }
/** /**
@ -287,7 +287,7 @@ class DBA extends BaseObject
*/ */
public static function lock($table) public static function lock($table)
{ {
return self::getClass(Database::class)->lock($table); return DI::dba()->lock($table);
} }
/** /**
@ -298,7 +298,7 @@ class DBA extends BaseObject
*/ */
public static function unlock() public static function unlock()
{ {
return self::getClass(Database::class)->unlock(); return DI::dba()->unlock();
} }
/** /**
@ -308,7 +308,7 @@ class DBA extends BaseObject
*/ */
public static function transaction() public static function transaction()
{ {
return self::getClass(Database::class)->transaction(); return DI::dba()->transaction();
} }
/** /**
@ -318,7 +318,7 @@ class DBA extends BaseObject
*/ */
public static function commit() public static function commit()
{ {
return self::getClass(Database::class)->commit(); return DI::dba()->commit();
} }
/** /**
@ -328,7 +328,7 @@ class DBA extends BaseObject
*/ */
public static function rollback() public static function rollback()
{ {
return self::getClass(Database::class)->rollback(); return DI::dba()->rollback();
} }
/** /**
@ -345,7 +345,7 @@ class DBA extends BaseObject
*/ */
public static function delete($table, array $conditions, array $options = []) public static function delete($table, array $conditions, array $options = [])
{ {
return self::getClass(Database::class)->delete($table, $conditions, $options); return DI::dba()->delete($table, $conditions, $options);
} }
/** /**
@ -379,7 +379,7 @@ class DBA extends BaseObject
*/ */
public static function update($table, $fields, $condition, $old_fields = []) public static function update($table, $fields, $condition, $old_fields = [])
{ {
return self::getClass(Database::class)->update($table, $fields, $condition, $old_fields); return DI::dba()->update($table, $fields, $condition, $old_fields);
} }
/** /**
@ -396,7 +396,7 @@ class DBA extends BaseObject
*/ */
public static function selectFirst($table, array $fields = [], array $condition = [], $params = []) public static function selectFirst($table, array $fields = [], array $condition = [], $params = [])
{ {
return self::getClass(Database::class)->selectFirst($table, $fields, $condition, $params); return DI::dba()->selectFirst($table, $fields, $condition, $params);
} }
/** /**
@ -413,7 +413,7 @@ class DBA extends BaseObject
*/ */
public static function selectToArray($table, array $fields = [], array $condition = [], array $params = []) public static function selectToArray($table, array $fields = [], array $condition = [], array $params = [])
{ {
return self::getClass(Database::class)->selectToArray($table, $fields, $condition, $params); return DI::dba()->selectToArray($table, $fields, $condition, $params);
} }
/** /**
@ -441,7 +441,7 @@ class DBA extends BaseObject
*/ */
public static function select($table, array $fields = [], array $condition = [], array $params = []) public static function select($table, array $fields = [], array $condition = [], array $params = [])
{ {
return self::getClass(Database::class)->select($table, $fields, $condition, $params); return DI::dba()->select($table, $fields, $condition, $params);
} }
/** /**
@ -465,7 +465,7 @@ class DBA extends BaseObject
*/ */
public static function count($table, array $condition = [], array $params = []) public static function count($table, array $condition = [], array $params = [])
{ {
return self::getClass(Database::class)->count($table, $condition, $params); return DI::dba()->count($table, $condition, $params);
} }
/** /**
@ -639,7 +639,7 @@ class DBA extends BaseObject
*/ */
public static function toArray($stmt, $do_close = true) public static function toArray($stmt, $do_close = true)
{ {
return self::getClass(Database::class)->toArray($stmt, $do_close); return DI::dba()->toArray($stmt, $do_close);
} }
/** /**
@ -649,7 +649,7 @@ class DBA extends BaseObject
*/ */
public static function errorNo() public static function errorNo()
{ {
return self::getClass(Database::class)->errorNo(); return DI::dba()->errorNo();
} }
/** /**
@ -659,7 +659,7 @@ class DBA extends BaseObject
*/ */
public static function errorMessage() public static function errorMessage()
{ {
return self::getClass(Database::class)->errorMessage(); return DI::dba()->errorMessage();
} }
/** /**
@ -670,7 +670,7 @@ class DBA extends BaseObject
*/ */
public static function close($stmt) public static function close($stmt)
{ {
return self::getClass(Database::class)->close($stmt); return DI::dba()->close($stmt);
} }
/** /**
@ -683,7 +683,7 @@ class DBA extends BaseObject
*/ */
public static function processlist() public static function processlist()
{ {
return self::getClass(Database::class)->processlist(); return DI::dba()->processlist();
} }
/** /**
@ -695,7 +695,7 @@ class DBA extends BaseObject
*/ */
public static function isResult($array) public static function isResult($array)
{ {
return self::getClass(Database::class)->isResult($array); return DI::dba()->isResult($array);
} }
/** /**
@ -707,6 +707,6 @@ class DBA extends BaseObject
*/ */
public static function escapeArray(&$arr, $add_quotation = false) public static function escapeArray(&$arr, $add_quotation = false)
{ {
return self::getClass(Database::class)->escapeArray($arr, $add_quotation); DI::dba()->escapeArray($arr, $add_quotation);
} }
} }

View file

@ -6,7 +6,6 @@
namespace Friendica\Model; namespace Friendica\Model;
use Friendica\BaseObject;
use Friendica\Content\Text\HTML; use Friendica\Content\Text\HTML;
use Friendica\Core\Logger; use Friendica\Core\Logger;
use Friendica\Core\Config; use Friendica\Core\Config;
@ -17,7 +16,7 @@ use Friendica\Util\JsonLD;
use Friendica\Util\DateTimeFormat; use Friendica\Util\DateTimeFormat;
use Friendica\Util\Strings; use Friendica\Util\Strings;
class APContact extends BaseObject class APContact
{ {
/** /**
* Resolves the profile url from the address by using webfinger * Resolves the profile url from the address by using webfinger

View file

@ -6,7 +6,6 @@
*/ */
namespace Friendica\Model; namespace Friendica\Model;
use Friendica\BaseObject;
use Friendica\Core\StorageManager; use Friendica\Core\StorageManager;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\Database\DBA; use Friendica\Database\DBA;
@ -21,7 +20,7 @@ use Friendica\Util\Security;
/** /**
* Class to handle attach dabatase table * Class to handle attach dabatase table
*/ */
class Attach extends BaseObject class Attach
{ {
/** /**

View file

@ -5,7 +5,6 @@
namespace Friendica\Model; namespace Friendica\Model;
use Friendica\App\BaseURL; use Friendica\App\BaseURL;
use Friendica\BaseObject;
use Friendica\Content\Pager; use Friendica\Content\Pager;
use Friendica\Core\Config; use Friendica\Core\Config;
use Friendica\Core\Hook; use Friendica\Core\Hook;
@ -18,7 +17,6 @@ use Friendica\Core\Worker;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI; use Friendica\DI;
use Friendica\Network\Probe; use Friendica\Network\Probe;
use Friendica\Object\Image;
use Friendica\Protocol\Activity; use Friendica\Protocol\Activity;
use Friendica\Protocol\ActivityPub; use Friendica\Protocol\ActivityPub;
use Friendica\Protocol\DFRN; use Friendica\Protocol\DFRN;
@ -33,7 +31,7 @@ use Friendica\Util\Strings;
/** /**
* @brief functions for interacting with a contact * @brief functions for interacting with a contact
*/ */
class Contact extends BaseObject class Contact
{ {
/** /**
* @deprecated since version 2019.03 * @deprecated since version 2019.03

View file

@ -5,7 +5,6 @@
namespace Friendica\Model; namespace Friendica\Model;
use Friendica\BaseObject;
use Friendica\Content\Text\BBCode; use Friendica\Content\Text\BBCode;
use Friendica\Core\Hook; use Friendica\Core\Hook;
use Friendica\Core\L10n; use Friendica\Core\L10n;
@ -23,7 +22,7 @@ use Friendica\Util\XML;
/** /**
* @brief functions for interacting with the event database table * @brief functions for interacting with the event database table
*/ */
class Event extends BaseObject class Event
{ {
public static function getHTML(array $event, $simple = false) public static function getHTML(array $event, $simple = false)

View file

@ -6,7 +6,6 @@
namespace Friendica\Model; namespace Friendica\Model;
use Friendica\BaseModule; use Friendica\BaseModule;
use Friendica\BaseObject;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\Core\Logger; use Friendica\Core\Logger;
use Friendica\Core\Protocol; use Friendica\Core\Protocol;
@ -16,7 +15,7 @@ use Friendica\Database\DBA;
/** /**
* @brief functions for interacting with the group database table * @brief functions for interacting with the group database table
*/ */
class Group extends BaseObject class Group
{ {
const FOLLOWERS = '~'; const FOLLOWERS = '~';
const MUTUALS = '&'; const MUTUALS = '&';

View file

@ -6,7 +6,6 @@
namespace Friendica\Model; namespace Friendica\Model;
use Friendica\BaseObject;
use Friendica\Content\Text\BBCode; use Friendica\Content\Text\BBCode;
use Friendica\Content\Text\HTML; use Friendica\Content\Text\HTML;
use Friendica\Core\Config; use Friendica\Core\Config;
@ -26,7 +25,6 @@ use Friendica\Protocol\Activity;
use Friendica\Protocol\ActivityPub; use Friendica\Protocol\ActivityPub;
use Friendica\Protocol\Diaspora; use Friendica\Protocol\Diaspora;
use Friendica\Protocol\OStatus; use Friendica\Protocol\OStatus;
use Friendica\Util\ACLFormatter;
use Friendica\Util\DateTimeFormat; use Friendica\Util\DateTimeFormat;
use Friendica\Util\Map; use Friendica\Util\Map;
use Friendica\Util\Network; use Friendica\Util\Network;
@ -36,7 +34,7 @@ use Friendica\Util\XML;
use Friendica\Worker\Delivery; use Friendica\Worker\Delivery;
use Text_LanguageDetect; use Text_LanguageDetect;
class Item extends BaseObject class Item
{ {
// Posting types, inspired by https://www.w3.org/TR/activitystreams-vocabulary/#object-types // Posting types, inspired by https://www.w3.org/TR/activitystreams-vocabulary/#object-types
const PT_ARTICLE = 0; const PT_ARTICLE = 0;
@ -1442,8 +1440,7 @@ class Item extends BaseObject
$item['parent-uri'] = $item['thr-parent']; $item['parent-uri'] = $item['thr-parent'];
} }
/** @var Activity $activity */ $activity = DI::activity();
$activity = self::getClass(Activity::class);
if (isset($item['gravity'])) { if (isset($item['gravity'])) {
$item['gravity'] = intval($item['gravity']); $item['gravity'] = intval($item['gravity']);
@ -2980,8 +2977,7 @@ class Item extends BaseObject
*/ */
public static function enumeratePermissions(array $obj, bool $check_dead = false) public static function enumeratePermissions(array $obj, bool $check_dead = false)
{ {
/** @var ACLFormatter $aclFormater */ $aclFormater = DI::aclFormatter();
$aclFormater = self::getClass(ACLFormatter::class);
$allow_people = $aclFormater->expand($obj['allow_cid']); $allow_people = $aclFormater->expand($obj['allow_cid']);
$allow_groups = Group::expand($obj['uid'], $aclFormater->expand($obj['allow_gid']), $check_dead); $allow_groups = Group::expand($obj['uid'], $aclFormater->expand($obj['allow_gid']), $check_dead);

View file

@ -6,12 +6,11 @@
namespace Friendica\Model; namespace Friendica\Model;
use Friendica\BaseObject;
use Friendica\Content\Text; use Friendica\Content\Text;
use Friendica\Core\PConfig; use Friendica\Core\PConfig;
use Friendica\Core\Protocol; use Friendica\Core\Protocol;
class ItemContent extends BaseObject class ItemContent
{ {
/** /**
* @brief Convert a message into plaintext for connectors to other networks * @brief Convert a message into plaintext for connectors to other networks

View file

@ -6,10 +6,9 @@
namespace Friendica\Model; namespace Friendica\Model;
use Friendica\BaseObject;
use Friendica\Database\DBA; use Friendica\Database\DBA;
class ItemURI extends BaseObject class ItemURI
{ {
/** /**
* @brief Insert an item-uri record and return its id * @brief Insert an item-uri record and return its id

View file

@ -2,7 +2,6 @@
namespace Friendica\Model; namespace Friendica\Model;
use Friendica\BaseObject;
use Friendica\Core\Addon; use Friendica\Core\Addon;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI; use Friendica\DI;
@ -10,7 +9,7 @@ use Friendica\DI;
/** /**
* Model interaction for the nodeinfo * Model interaction for the nodeinfo
*/ */
class Nodeinfo extends BaseObject class Nodeinfo
{ {
/** /**
* Updates the info about the current node * Updates the info about the current node

View file

@ -4,7 +4,6 @@ namespace Friendica\Model;
use Exception; use Exception;
use Friendica\App; use Friendica\App;
use Friendica\BaseObject;
use Friendica\Content\Text\BBCode; use Friendica\Content\Text\BBCode;
use Friendica\Content\Text\HTML; use Friendica\Content\Text\HTML;
use Friendica\Core\Config\PConfiguration; use Friendica\Core\Config\PConfiguration;
@ -26,7 +25,7 @@ use Friendica\Network\HTTPException;
* @brief Methods for read and write notifications from/to database * @brief Methods for read and write notifications from/to database
* or for formatting notifications * or for formatting notifications
*/ */
final class Notify extends BaseObject final class Notify
{ {
/** @var int The default limit of notifies per page */ /** @var int The default limit of notifies per page */
const DEFAULT_PAGE_LIMIT = 80; const DEFAULT_PAGE_LIMIT = 80;

View file

@ -4,13 +4,12 @@
*/ */
namespace Friendica\Model; namespace Friendica\Model;
use Friendica\BaseObject;
use Friendica\Database\DBA; use Friendica\Database\DBA;
/** /**
* @brief functions for interacting with the permission set of an object (item, photo, event, ...) * @brief functions for interacting with the permission set of an object (item, photo, event, ...)
*/ */
class PermissionSet extends BaseObject class PermissionSet
{ {
/** /**
* Fetch the id of a given permission set. Generate a new one when needed * Fetch the id of a given permission set. Generate a new one when needed

View file

@ -6,7 +6,6 @@
*/ */
namespace Friendica\Model; namespace Friendica\Model;
use Friendica\BaseObject;
use Friendica\Core\Cache; use Friendica\Core\Cache;
use Friendica\Core\Config; use Friendica\Core\Config;
use Friendica\Core\L10n; use Friendica\Core\L10n;
@ -29,7 +28,7 @@ require_once "include/dba.php";
/** /**
* Class to handle photo dabatase table * Class to handle photo dabatase table
*/ */
class Photo extends BaseObject class Photo
{ {
/** /**
* @brief Select rows from the photo table and returns them as array * @brief Select rows from the photo table and returns them as array

View file

@ -4,14 +4,13 @@
*/ */
namespace Friendica\Model; namespace Friendica\Model;
use Friendica\BaseObject;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\Util\DateTimeFormat; use Friendica\Util\DateTimeFormat;
/** /**
* @brief functions for interacting with a process * @brief functions for interacting with a process
*/ */
class Process extends BaseObject class Process
{ {
/** /**
* Insert a new process row. If the pid parameter is omitted, we use the current pid * Insert a new process row. If the pid parameter is omitted, we use the current pid

View file

@ -2,13 +2,12 @@
namespace Friendica\Model; namespace Friendica\Model;
use Friendica\BaseObject;
use Friendica\Database\DBA; use Friendica\Database\DBA;
/** /**
* Model for DB specific logic for the search entity * Model for DB specific logic for the search entity
*/ */
class Search extends BaseObject class Search
{ {
/** /**
* Returns the list of user defined tags (e.g. #Friendica) * Returns the list of user defined tags (e.g. #Friendica)

View file

@ -2,7 +2,6 @@
namespace Friendica\Model\TwoFactor; namespace Friendica\Model\TwoFactor;
use Friendica\BaseObject;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\Model\User; use Friendica\Model\User;
use Friendica\Util\DateTimeFormat; use Friendica\Util\DateTimeFormat;
@ -14,7 +13,7 @@ use PragmaRX\Random\Random;
* *
* @package Friendica\Model * @package Friendica\Model
*/ */
class AppSpecificPassword extends BaseObject class AppSpecificPassword
{ {
public static function countForUser($uid) public static function countForUser($uid)
{ {

View file

@ -2,7 +2,6 @@
namespace Friendica\Model\TwoFactor; namespace Friendica\Model\TwoFactor;
use Friendica\BaseObject;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\Util\DateTimeFormat; use Friendica\Util\DateTimeFormat;
use PragmaRX\Random\Random; use PragmaRX\Random\Random;
@ -13,7 +12,7 @@ use PragmaRX\Recovery\Recovery;
* *
* @package Friendica\Model * @package Friendica\Model
*/ */
class RecoveryCode extends BaseObject class RecoveryCode
{ {
/** /**
* Returns the number of code the provided users can still use to replace a TOTP code * Returns the number of code the provided users can still use to replace a TOTP code

View file

@ -81,8 +81,7 @@ class Summary extends BaseAdminModule
if (Config::get('system', 'debugging')) { if (Config::get('system', 'debugging')) {
$file = Config::get('system', 'logfile'); $file = Config::get('system', 'logfile');
/** @var FileSystem $fileSystem */ $fileSystem = DI::fs();
$fileSystem = self::getClass(FileSystem::class);
try { try {
$stream = $fileSystem->createStream($file); $stream = $fileSystem->createStream($file);

View file

@ -3,10 +3,10 @@
namespace Friendica\Module\Api\Mastodon; namespace Friendica\Module\Api\Mastodon;
use Friendica\Api\Mastodon; use Friendica\Api\Mastodon;
use Friendica\App\BaseURL;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\Model\APContact; use Friendica\Model\APContact;
use Friendica\DI;
use Friendica\Model\Contact; use Friendica\Model\Contact;
use Friendica\Model\Introduction; use Friendica\Model\Introduction;
use Friendica\Module\Base\Api; use Friendica\Module\Base\Api;
@ -104,8 +104,7 @@ class FollowRequests extends Api
$base_query['limit'] = $limit; $base_query['limit'] = $limit;
} }
/** @var BaseURL $BaseURL */ $BaseURL = DI::baseUrl();
$BaseURL = self::getClass(BaseURL::class);
$links = []; $links = [];
if ($count > $limit) { if ($count > $limit) {

View file

@ -23,15 +23,15 @@ class Api extends BaseModule
public static function init(array $parameters = []) public static function init(array $parameters = [])
{ {
$Arguments = self::getClass(Arguments::class); $arguments = DI::args();
if (substr($Arguments->getQueryString(), -4) === '.xml') { if (substr($arguments->getQueryString(), -4) === '.xml') {
self::$format = 'xml'; self::$format = 'xml';
} }
if (substr($Arguments->getQueryString(), -4) === '.rss') { if (substr($arguments->getQueryString(), -4) === '.rss') {
self::$format = 'rss'; self::$format = 'rss';
} }
if (substr($Arguments->getQueryString(), -4) === '.atom') { if (substr($arguments->getQueryString(), -4) === '.atom') {
self::$format = 'atom'; self::$format = 'atom';
} }
} }

View file

@ -65,8 +65,7 @@ class BaseSearchModule extends BaseModule
$header = L10n::t('Forum Search - %s', $search); $header = L10n::t('Forum Search - %s', $search);
} }
/** @var Arguments $args */ $args = DI::args();
$args = self::getClass(Arguments::class);
$pager = new Pager($args->getQueryString()); $pager = new Pager($args->getQueryString());
if ($localSearch && empty($results)) { if ($localSearch && empty($results)) {

View file

@ -3,7 +3,6 @@
namespace Friendica\Module; namespace Friendica\Module;
use Friendica\BaseModule; use Friendica\BaseModule;
use Friendica\App\Authentication;
use Friendica\Core\Hook; use Friendica\Core\Hook;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
@ -81,9 +80,7 @@ class Delegation extends BaseModule
Session::clear(); Session::clear();
/** @var Authentication $authentication */ DI::auth()->setForUser(DI::app(), $user, true, true);
$authentication = self::getClass(Authentication::class);
$authentication->setForUser(DI::app(), $user, true, true);
if ($limited_id) { if ($limited_id) {
Session::set('submanage', $original_id); Session::set('submanage', $original_id);

View file

@ -6,6 +6,7 @@ use Friendica\App;
use Friendica\BaseModule; use Friendica\BaseModule;
use Friendica\Core\Config\Configuration; use Friendica\Core\Config\Configuration;
use Friendica\Core\L10n\L10n; use Friendica\Core\L10n\L10n;
use Friendica\DI;
use Friendica\Model\User; use Friendica\Model\User;
use Friendica\Network\HTTPException; use Friendica\Network\HTTPException;
use Friendica\Protocol\Diaspora; use Friendica\Protocol\Diaspora;
@ -23,24 +24,18 @@ class Receive extends BaseModule
public static function init(array $parameters = []) public static function init(array $parameters = [])
{ {
/** @var LoggerInterface $logger */ self::$logger = DI::logger();
self::$logger = self::getClass(LoggerInterface::class);
} }
public static function post(array $parameters = []) public static function post(array $parameters = [])
{ {
/** @var Configuration $config */ $enabled = DI::config()->get('system', 'diaspora_enabled', false);
$config = self::getClass(Configuration::class);
$enabled = $config->get('system', 'diaspora_enabled', false);
if (!$enabled) { if (!$enabled) {
self::$logger->info('Diaspora disabled.'); self::$logger->info('Diaspora disabled.');
$l10n = self::getClass(L10n::class); throw new HTTPException\ForbiddenException(DI::l10n()->t('Access denied.'));
throw new HTTPException\ForbiddenException($l10n->t('Access denied.'));
} }
/** @var App\Arguments $args */ $args = DI::args();
$args = self::getClass(App\Arguments::class);
$type = $args->get(1); $type = $args->get(1);

View file

@ -63,8 +63,7 @@ class Compose extends BaseModule
$user = User::getById(local_user(), ['allow_cid', 'allow_gid', 'deny_cid', 'deny_gid', 'hidewall', 'default-location']); $user = User::getById(local_user(), ['allow_cid', 'allow_gid', 'deny_cid', 'deny_gid', 'hidewall', 'default-location']);
/** @var ACLFormatter $aclFormatter */ $aclFormatter = DI::aclFormatter();
$aclFormatter = self::getClass(ACLFormatter::class);
$contact_allow_list = $aclFormatter->expand($user['allow_cid']); $contact_allow_list = $aclFormatter->expand($user['allow_cid']);
$group_allow_list = $aclFormatter->expand($user['allow_gid']); $group_allow_list = $aclFormatter->expand($user['allow_gid']);

View file

@ -19,17 +19,14 @@ class Ignore extends BaseModule
{ {
public static function rawContent(array $parameters = []) public static function rawContent(array $parameters = [])
{ {
/** @var L10n $l10n */ $l10n = DI::l10n();
$l10n = self::getClass(L10n::class);
if (!Session::isAuthenticated()) { if (!Session::isAuthenticated()) {
throw new HttpException\ForbiddenException($l10n->t('Access denied.')); throw new HttpException\ForbiddenException($l10n->t('Access denied.'));
} }
/** @var App\Arguments $args */ $args = DI::args();
$args = self::getClass(App\Arguments::class); $dba = DI::dba();
/** @var Database $dba */
$dba = self::getClass(Database::class);
$message_id = intval($args->get(2)); $message_id = intval($args->get(2));

View file

@ -3,11 +3,9 @@
namespace Friendica\Module\Notifications; namespace Friendica\Module\Notifications;
use Friendica\BaseModule; use Friendica\BaseModule;
use Friendica\BaseObject;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\DI; use Friendica\DI;
use Friendica\Model\Notify as ModelNotify;
use Friendica\Network\HTTPException; use Friendica\Network\HTTPException;
/** /**
@ -28,9 +26,7 @@ class Notify extends BaseModule
// @TODO: Replace with parameter from router // @TODO: Replace with parameter from router
if ($a->argc > 2 && $a->argv[1] === 'mark' && $a->argv[2] === 'all') { if ($a->argc > 2 && $a->argv[1] === 'mark' && $a->argv[2] === 'all') {
/** @var ModelNotify $notificationsManager */ $success = DI::notify()->setAllSeen();
$notificationsManager = self::getClass(ModelNotify::class);
$success = $notificationsManager->setAllSeen();
header('Content-type: application/json; charset=utf-8'); header('Content-type: application/json; charset=utf-8');
echo json_encode([ echo json_encode([
@ -52,8 +48,7 @@ class Notify extends BaseModule
// @TODO: Replace with parameter from router // @TODO: Replace with parameter from router
if ($a->argc > 2 && $a->argv[1] === 'view' && intval($a->argv[2])) { if ($a->argc > 2 && $a->argv[1] === 'view' && intval($a->argv[2])) {
/** @var ModelNotify $notificationsManager */ $notificationsManager = DI::notify();
$notificationsManager = BaseObject::getClass(ModelNotify::class);
// @TODO: Replace with parameter from router // @TODO: Replace with parameter from router
$note = $notificationsManager->getByID($a->argv[2]); $note = $notificationsManager->getByID($a->argv[2]);
if (!empty($note)) { if (!empty($note)) {

View file

@ -133,12 +133,9 @@ class Profile extends BaseModule
$category = $datequery = $datequery2 = ''; $category = $datequery = $datequery2 = '';
/** @var DateTimeFormat $dtFormat */
$dtFormat = self::getClass(DateTimeFormat::class);
if ($a->argc > 2) { if ($a->argc > 2) {
for ($x = 2; $x < $a->argc; $x ++) { for ($x = 2; $x < $a->argc; $x ++) {
if ($dtFormat->isYearMonth($a->argv[$x])) { if (DI::dtFormat()->isYearMonth($a->argv[$x])) {
if ($datequery) { if ($datequery) {
$datequery2 = Strings::escapeHtml($a->argv[$x]); $datequery2 = Strings::escapeHtml($a->argv[$x]);
} else { } else {

View file

@ -209,7 +209,7 @@ class Register extends BaseModule
$user = $result['user']; $user = $result['user'];
$base_url = self::getClass(BaseURL::class)->get(); $base_url = DI::baseUrl()->get();
if ($netpublish && intval(Config::get('config', 'register_policy')) !== self::APPROVE) { if ($netpublish && intval(Config::get('config', 'register_policy')) !== self::APPROVE) {
$url = $base_url . '/profile/' . $user['nickname']; $url = $base_url . '/profile/' . $user['nickname'];

View file

@ -126,9 +126,7 @@ class Index extends BaseSearchModule
// OR your own posts if you are a logged in member // OR your own posts if you are a logged in member
// No items will be shown if the member has a blocked profile wall. // No items will be shown if the member has a blocked profile wall.
/** @var Arguments $args */ $pager = new Pager(DI::args()->getQueryString());
$args = self::getClass(Arguments::class);
$pager = new Pager($args->getQueryString());
if ($tag) { if ($tag) {
Logger::info('Start tag search.', ['q' => $search]); Logger::info('Start tag search.', ['q' => $search]);

View file

@ -2,7 +2,6 @@
namespace Friendica\Module\Search; namespace Friendica\Module\Search;
use Friendica\App\Arguments;
use Friendica\BaseModule; use Friendica\BaseModule;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\Database\DBA; use Friendica\Database\DBA;
@ -13,10 +12,7 @@ class Saved extends BaseModule
{ {
public static function init(array $parameters = []) public static function init(array $parameters = [])
{ {
/** @var Arguments $args */ $action = DI::args()->get(2, 'none');
$args = self::getClass(Arguments::class);
$action = $args->get(2, 'none');
$search = Strings::escapeTags(trim(rawurldecode($_GET['term'] ?? ''))); $search = Strings::escapeTags(trim(rawurldecode($_GET['term'] ?? '')));
$return_url = $_GET['return_url'] ?? 'search?q=' . urlencode($search); $return_url = $_GET['return_url'] ?? 'search?q=' . urlencode($search);

View file

@ -7,7 +7,6 @@
namespace Friendica\Module\Security; namespace Friendica\Module\Security;
use Friendica\BaseModule; use Friendica\BaseModule;
use Friendica\App\Authentication;
use Friendica\Core\Config; use Friendica\Core\Config;
use Friendica\Core\Hook; use Friendica\Core\Hook;
use Friendica\Core\L10n; use Friendica\Core\L10n;
@ -49,15 +48,11 @@ class Login extends BaseModule
) { ) {
$openid_url = trim(($_POST['openid_url'] ?? '') ?: $_POST['username']); $openid_url = trim(($_POST['openid_url'] ?? '') ?: $_POST['username']);
/** @var Authentication $authentication */ DI::auth()->withOpenId($openid_url, !empty($_POST['remember']));
$authentication = self::getClass(Authentication::class);
$authentication->withOpenId($openid_url, !empty($_POST['remember']));
} }
if (!empty($_POST['auth-params']) && $_POST['auth-params'] === 'login') { if (!empty($_POST['auth-params']) && $_POST['auth-params'] === 'login') {
/** @var Authentication $authentication */ DI::auth()->withPassword(
$authentication = self::getClass(Authentication::class);
$authentication->withPassword(
DI::app(), DI::app(),
trim($_POST['username']), trim($_POST['username']),
trim($_POST['password']), trim($_POST['password']),

View file

@ -42,10 +42,7 @@ class Recovery extends BaseModule
Session::set('2fa', true); Session::set('2fa', true);
notice(L10n::t('Remaining recovery codes: %d', RecoveryCode::countValidForUser(local_user()))); notice(L10n::t('Remaining recovery codes: %d', RecoveryCode::countValidForUser(local_user())));
// Resume normal login workflow DI::auth()->setForUser($a, $a->user, true, true);
/** @var Authentication $authentication */
$authentication = self::getClass(Authentication::class);
$authentication->setForUser($a, $a->user, true, true);
} else { } else {
notice(L10n::t('Invalid code, please retry.')); notice(L10n::t('Invalid code, please retry.'));
} }

View file

@ -40,9 +40,7 @@ class Verify extends BaseModule
Session::set('2fa', $code); Session::set('2fa', $code);
// Resume normal login workflow // Resume normal login workflow
/** @var Authentication $authentication */ DI::auth()->setForUser($a, $a->user, true, true);
$authentication = self::getClass(Authentication::class);
$authentication->setForUser($a, $a->user, true, true);
} else { } else {
self::$errors[] = L10n::t('Invalid code, please retry.'); self::$errors[] = L10n::t('Invalid code, please retry.');
} }

View file

@ -55,8 +55,7 @@ class Delegation extends BaseSettingsModule
throw new HTTPException\ForbiddenException(L10n::t('Permission denied.')); throw new HTTPException\ForbiddenException(L10n::t('Permission denied.'));
} }
/** @var Arguments $args */ $args = DI::args();
$args = self::getClass(Arguments::class);
// @TODO Replace with router-provided arguments // @TODO Replace with router-provided arguments
$action = $args->get(2); $action = $args->get(2);

View file

@ -62,7 +62,7 @@ class UserExport extends BaseSettingsModule
**/ **/
public static function rawContent(array $parameters = []) public static function rawContent(array $parameters = [])
{ {
$args = self::getClass(Arguments::class); $args = DI::args();
if ($args->getArgc() == 3) { if ($args->getArgc() == 3) {
// @TODO Replace with router-provided arguments // @TODO Replace with router-provided arguments
$action = $args->get(2); $action = $args->get(2);

View file

@ -4,10 +4,7 @@
*/ */
namespace Friendica\Network; namespace Friendica\Network;
use Friendica\BaseObject;
use Friendica\App\Authentication;
use Friendica\Core\Logger; use Friendica\Core\Logger;
use Friendica\Core\Session;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI; use Friendica\DI;
use OAuthServer; use OAuthServer;
@ -47,8 +44,6 @@ class FKOAuth1 extends OAuthServer
die('This api requires login'); die('This api requires login');
} }
/** @var Authentication $authentication */ DI::auth()->setForUser($a, $record, true);
$authentication = BaseObject::getClass(Authentication::class);
$authentication->setForUser($a, $record, true);
} }
} }

View file

@ -4,10 +4,8 @@
*/ */
namespace Friendica\Object; namespace Friendica\Object;
use Friendica\BaseObject;
use Friendica\Content\ContactSelector; use Friendica\Content\ContactSelector;
use Friendica\Content\Feature; use Friendica\Content\Feature;
use Friendica\Content\Item as ContentItem;
use Friendica\Core\Addon; use Friendica\Core\Addon;
use Friendica\Core\Config; use Friendica\Core\Config;
use Friendica\Core\Hook; use Friendica\Core\Hook;
@ -33,7 +31,7 @@ use Friendica\Util\Temporal;
/** /**
* An item * An item
*/ */
class Post extends BaseObject class Post
{ {
private $data = []; private $data = [];
private $template = null; private $template = null;
@ -344,10 +342,7 @@ class Post extends BaseObject
$body = Item::prepareBody($item, true); $body = Item::prepareBody($item, true);
/** @var ContentItem $contItem */ list($categories, $folders) = DI::contentItem()->determineCategoriesTerms($item);
$contItem = self::getClass(ContentItem::class);
list($categories, $folders) = $contItem->determineCategoriesTerms($item);
$body_e = $body; $body_e = $body;
$text_e = strip_tags($body); $text_e = strip_tags($body);
@ -551,8 +546,7 @@ class Post extends BaseObject
return false; return false;
} }
/** @var Activity $activity */ $activity = DI::activity();
$activity = self::getClass(Activity::class);
/* /*
* Only add what will be displayed * Only add what will be displayed

View file

@ -4,7 +4,6 @@
*/ */
namespace Friendica\Object; namespace Friendica\Object;
use Friendica\BaseObject;
use Friendica\Core\Logger; use Friendica\Core\Logger;
use Friendica\Core\Protocol; use Friendica\Core\Protocol;
use Friendica\DI; use Friendica\DI;
@ -16,7 +15,7 @@ use Friendica\Util\Security;
* *
* We should think about making this a SPL Iterator * We should think about making this a SPL Iterator
*/ */
class Thread extends BaseObject class Thread
{ {
private $parents = []; private $parents = [];
private $mode = null; private $mode = null;

View file

@ -4,7 +4,6 @@
*/ */
namespace Friendica\Protocol\ActivityPub; namespace Friendica\Protocol\ActivityPub;
use Friendica\BaseObject;
use Friendica\Content\Feature; use Friendica\Content\Feature;
use Friendica\Content\Text\BBCode; use Friendica\Content\Text\BBCode;
use Friendica\Content\Text\Plaintext; use Friendica\Content\Text\Plaintext;

View file

@ -11,7 +11,6 @@ namespace Friendica\Protocol;
use DOMDocument; use DOMDocument;
use DOMXPath; use DOMXPath;
use Friendica\App\BaseURL; use Friendica\App\BaseURL;
use Friendica\BaseObject;
use Friendica\Content\OEmbed; use Friendica\Content\OEmbed;
use Friendica\Content\Text\BBCode; use Friendica\Content\Text\BBCode;
use Friendica\Content\Text\HTML; use Friendica\Content\Text\HTML;
@ -21,6 +20,7 @@ use Friendica\Core\Logger;
use Friendica\Core\Protocol; use Friendica\Core\Protocol;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact; use Friendica\Model\Contact;
use Friendica\Model\Conversation; use Friendica\Model\Conversation;
use Friendica\Model\Event; use Friendica\Model\Event;
@ -31,8 +31,6 @@ use Friendica\Model\PermissionSet;
use Friendica\Model\Profile; use Friendica\Model\Profile;
use Friendica\Model\User; use Friendica\Model\User;
use Friendica\Network\Probe; use Friendica\Network\Probe;
use Friendica\Object\Image;
use Friendica\Protocol\ActivityNamespace;
use Friendica\Util\Crypto; use Friendica\Util\Crypto;
use Friendica\Util\DateTimeFormat; use Friendica\Util\DateTimeFormat;
use Friendica\Util\Images; use Friendica\Util\Images;
@ -2181,8 +2179,7 @@ class DFRN
// The functions below are partly used by ostatus.php as well - where we have this variable // The functions below are partly used by ostatus.php as well - where we have this variable
$contact = Contact::selectFirst([], ['id' => $importer['id']]); $contact = Contact::selectFirst([], ['id' => $importer['id']]);
/** @var Activity $activity */ $activity = DI::activity();
$activity = BaseObject::getClass(Activity::class);
// Big question: Do we need these functions? They were part of the "consume_feed" function. // Big question: Do we need these functions? They were part of the "consume_feed" function.
// This function once was responsible for DFRN and OStatus. // This function once was responsible for DFRN and OStatus.

View file

@ -2,7 +2,6 @@
namespace Friendica\Util; namespace Friendica\Util;
use Friendica\BaseObject;
use Friendica\Core\Cache; use Friendica\Core\Cache;
use Friendica\Core\Logger; use Friendica\Core\Logger;
use Friendica\Core\System; use Friendica\Core\System;

View file

@ -2,7 +2,6 @@
namespace Friendica\Util; namespace Friendica\Util;
use Friendica\BaseObject;
use Friendica\Core\Config; use Friendica\Core\Config;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\DI; use Friendica\DI;

View file

@ -5,7 +5,6 @@
namespace Friendica\Util; namespace Friendica\Util;
use Friendica\BaseObject;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\Model\Contact; use Friendica\Model\Contact;
use Friendica\Model\Group; use Friendica\Model\Group;
@ -15,7 +14,7 @@ use Friendica\Core\Session;
/** /**
* Secures that User is allow to do requests * Secures that User is allow to do requests
*/ */
class Security extends BaseObject class Security
{ {
public static function canWriteToUserWall($owner) public static function canWriteToUserWall($owner)
{ {

View file

@ -4,14 +4,13 @@
*/ */
namespace Friendica\Worker; namespace Friendica\Worker;
use Friendica\BaseObject;
use Friendica\Core\Logger; use Friendica\Core\Logger;
use Friendica\Core\Worker; use Friendica\Core\Worker;
use Friendica\Model\ItemDeliveryData; use Friendica\Model\ItemDeliveryData;
use Friendica\Protocol\ActivityPub; use Friendica\Protocol\ActivityPub;
use Friendica\Util\HTTPSignature; use Friendica\Util\HTTPSignature;
class APDelivery extends BaseObject class APDelivery
{ {
/** /**
* @brief Delivers ActivityPub messages * @brief Delivers ActivityPub messages

View file

@ -4,7 +4,6 @@
*/ */
namespace Friendica\Worker; namespace Friendica\Worker;
use Friendica\BaseObject;
use Friendica\Core\Addon; use Friendica\Core\Addon;
use Friendica\Core\Config; use Friendica\Core\Config;
use Friendica\Core\Hook; use Friendica\Core\Hook;

View file

@ -5,7 +5,6 @@
namespace Friendica\Worker; namespace Friendica\Worker;
use Friendica\App; use Friendica\App;
use Friendica\BaseObject;
use Friendica\Core\Cache; use Friendica\Core\Cache;
use Friendica\Core\Config; use Friendica\Core\Config;
use Friendica\Core\Logger; use Friendica\Core\Logger;

View file

@ -5,12 +5,11 @@
*/ */
namespace Friendica\Worker; namespace Friendica\Worker;
use Friendica\BaseObject;
use Friendica\Core\Config; use Friendica\Core\Config;
use Friendica\Core\Update; use Friendica\Core\Update;
use Friendica\DI; use Friendica\DI;
class DBUpdate extends BaseObject class DBUpdate
{ {
public static function execute() public static function execute()
{ {

View file

@ -4,7 +4,6 @@
*/ */
namespace Friendica\Worker; namespace Friendica\Worker;
use Friendica\BaseObject;
use Friendica\Core\Config; use Friendica\Core\Config;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\Core\Logger; use Friendica\Core\Logger;
@ -21,7 +20,7 @@ use Friendica\Util\Strings;
use Friendica\Util\Network; use Friendica\Util\Network;
use Friendica\Core\Worker; use Friendica\Core\Worker;
class Delivery extends BaseObject class Delivery
{ {
const MAIL = 'mail'; const MAIL = 'mail';
const SUGGESTION = 'suggest'; const SUGGESTION = 'suggest';

View file

@ -6,7 +6,6 @@
namespace Friendica\Worker; namespace Friendica\Worker;
use Friendica\BaseObject;
use Friendica\Core\Config; use Friendica\Core\Config;
use Friendica\Core\Hook; use Friendica\Core\Hook;
use Friendica\Core\Logger; use Friendica\Core\Logger;

View file

@ -4,7 +4,6 @@
*/ */
namespace Friendica\Worker; namespace Friendica\Worker;
use Friendica\BaseObject;
use Friendica\Core\Config; use Friendica\Core\Config;
use Friendica\Core\Hook; use Friendica\Core\Hook;
use Friendica\Core\Logger; use Friendica\Core\Logger;
@ -279,8 +278,7 @@ class Notifier
$public_message = false; // private recipients, not public $public_message = false; // private recipients, not public
} }
/** @var ACLFormatter $aclFormatter */ $aclFormatter = DI::aclFormatter();
$aclFormatter = BaseObject::getClass(ACLFormatter::class);
$allow_people = $aclFormatter->expand($parent['allow_cid']); $allow_people = $aclFormatter->expand($parent['allow_cid']);
$allow_groups = Group::expand($uid, $aclFormatter->expand($parent['allow_gid']),true); $allow_groups = Group::expand($uid, $aclFormatter->expand($parent['allow_gid']),true);

View file

@ -4,8 +4,6 @@
*/ */
namespace Friendica\Worker; namespace Friendica\Worker;
use Friendica\BaseObject;
use Friendica\Content\Text\BBCode;
use Friendica\Core\Config; use Friendica\Core\Config;
use Friendica\Core\Logger; use Friendica\Core\Logger;
use Friendica\Core\PConfig; use Friendica\Core\PConfig;

View file

@ -6,7 +6,6 @@
namespace Friendica\Worker; namespace Friendica\Worker;
use Friendica\BaseObject;
use Friendica\Core\Logger; use Friendica\Core\Logger;
use Friendica\Core\Worker; use Friendica\Core\Worker;
use Friendica\DI; use Friendica\DI;

View file

@ -4,8 +4,8 @@ namespace Friendica\Test\Util;
use Dice\Dice; use Dice\Dice;
use Friendica\App; use Friendica\App;
use Friendica\BaseObject;
use Friendica\Core\Config; use Friendica\Core\Config;
use Friendica\DI;
use Friendica\Render\FriendicaSmartyEngine; use Friendica\Render\FriendicaSmartyEngine;
use Friendica\Util\Profiler; use Friendica\Util\Profiler;
use Mockery\MockInterface; use Mockery\MockInterface;
@ -109,7 +109,7 @@ trait AppMockTrait
return $this->configMock->get('system', 'url'); return $this->configMock->get('system', 'url');
}); });
BaseObject::setDependencyInjection($this->dice); DI::init($this->dice);
if ($raw) { if ($raw) {
return; return;

View file

@ -7,7 +7,6 @@ namespace Friendica\Test;
use Dice\Dice; use Dice\Dice;
use Friendica\App; use Friendica\App;
use Friendica\BaseObject;
use Friendica\Core\Config\Configuration; use Friendica\Core\Config\Configuration;
use Friendica\Core\Config\PConfiguration; use Friendica\Core\Config\PConfiguration;
use Friendica\Core\Protocol; use Friendica\Core\Protocol;
@ -65,7 +64,7 @@ class ApiTest extends DatabaseTest
->addRules(include __DIR__ . '/../../static/dependencies.config.php') ->addRules(include __DIR__ . '/../../static/dependencies.config.php')
->addRule(Database::class, ['instanceOf' => StaticDatabase::class, 'shared' => true]) ->addRule(Database::class, ['instanceOf' => StaticDatabase::class, 'shared' => true])
->addRule(ISession::class, ['instanceOf' => Session\Memory::class, 'shared' => true, 'call' => null]); ->addRule(ISession::class, ['instanceOf' => Session\Memory::class, 'shared' => true, 'call' => null]);
BaseObject::setDependencyInjection($this->dice); DI::init($this->dice);
/** @var Database $dba */ /** @var Database $dba */
$dba = $this->dice->create(Database::class); $dba = $this->dice->create(Database::class);
@ -116,8 +115,7 @@ class ApiTest extends DatabaseTest
// User ID that we know is not in the database // User ID that we know is not in the database
$this->wrongUserId = 666; $this->wrongUserId = 666;
/** @var ISession $session */ $session = DI::session();
$session = BaseObject::getClass(ISession::class);
$session->start(); $session->start();
// Most API require login so we force the session // Most API require login so we force the session

View file

@ -4,13 +4,13 @@ namespace Friendica\Test\src\Console;
use Dice\Dice; use Dice\Dice;
use Friendica\App; use Friendica\App;
use Friendica\BaseObject;
use Friendica\Console\AutomaticInstallation; use Friendica\Console\AutomaticInstallation;
use Friendica\Core\Config\Cache\ConfigCache; use Friendica\Core\Config\Cache\ConfigCache;
use Friendica\Core\Installer; use Friendica\Core\Installer;
use Friendica\Core\L10n\L10n; use Friendica\Core\L10n\L10n;
use Friendica\Core\Logger; use Friendica\Core\Logger;
use Friendica\Database\Database; use Friendica\Database\Database;
use Friendica\DI;
use Friendica\Test\Util\DBAMockTrait; use Friendica\Test\Util\DBAMockTrait;
use Friendica\Test\Util\DBStructureMockTrait; use Friendica\Test\Util\DBStructureMockTrait;
use Friendica\Test\Util\RendererMockTrait; use Friendica\Test\Util\RendererMockTrait;
@ -77,7 +77,7 @@ class AutomaticInstallationConsoleTest extends ConsoleTest
->with(L10n::class) ->with(L10n::class)
->andReturn($l10nMock); ->andReturn($l10nMock);
BaseObject::setDependencyInjection($this->dice); DI::init($this->dice);
$this->configCache = new ConfigCache(); $this->configCache = new ConfigCache();
$this->configCache->set('system', 'basepath', $this->root->url()); $this->configCache->set('system', 'basepath', $this->root->url());

View file

@ -4,10 +4,9 @@
namespace Friendica\Core; namespace Friendica\Core;
use Dice\Dice; use Dice\Dice;
use Friendica\BaseObject;
use Friendica\Core\Config\Cache\ConfigCache; use Friendica\Core\Config\Cache\ConfigCache;
use Friendica\DI;
use Friendica\Network\CurlResult; use Friendica\Network\CurlResult;
use Friendica\Object\Image;
use Friendica\Test\MockedTest; use Friendica\Test\MockedTest;
use Friendica\Test\Util\VFSTrait; use Friendica\Test\Util\VFSTrait;
use Friendica\Util\Network; use Friendica\Util\Network;
@ -38,7 +37,7 @@ class InstallerTest extends MockedTest
->with(\Friendica\Core\L10n\L10n::class) ->with(\Friendica\Core\L10n\L10n::class)
->andReturn($this->l10nMock); ->andReturn($this->l10nMock);
BaseObject::setDependencyInjection($dice); DI::init($dice);
} }
private function mockL10nT(string $text, $times = null) private function mockL10nT(string $text, $times = null)

View file

@ -4,9 +4,9 @@ namespace Friendica\Test\src\Core\Lock;
use Dice\Dice; use Dice\Dice;
use Friendica\App; use Friendica\App;
use Friendica\BaseObject;
use Friendica\Core\Config\Configuration; use Friendica\Core\Config\Configuration;
use Friendica\Core\Lock\SemaphoreLock; use Friendica\Core\Lock\SemaphoreLock;
use Friendica\DI;
class SemaphoreLockTest extends LockTest class SemaphoreLockTest extends LockTest
{ {
@ -26,7 +26,7 @@ class SemaphoreLockTest extends LockTest
$dice->shouldReceive('create')->with(Configuration::class)->andReturn($configMock); $dice->shouldReceive('create')->with(Configuration::class)->andReturn($configMock);
// @todo Because "get_temppath()" is using static methods, we have to initialize the BaseObject // @todo Because "get_temppath()" is using static methods, we have to initialize the BaseObject
BaseObject::setDependencyInjection($dice); DI::init($dice);
parent::setUp(); parent::setUp();
} }

View file

@ -2,10 +2,10 @@
namespace Friendica\Test\src\Database; namespace Friendica\Test\src\Database;
use Dice\Dice; use Dice\Dice;
use Friendica\BaseObject;
use Friendica\Core\Config; use Friendica\Core\Config;
use Friendica\Database\Database; use Friendica\Database\Database;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Test\DatabaseTest; use Friendica\Test\DatabaseTest;
use Friendica\Test\Util\Database\StaticDatabase; use Friendica\Test\Util\Database\StaticDatabase;
@ -18,7 +18,7 @@ class DBATest extends DatabaseTest
$dice = (new Dice()) $dice = (new Dice())
->addRules(include __DIR__ . '/../../../static/dependencies.config.php') ->addRules(include __DIR__ . '/../../../static/dependencies.config.php')
->addRule(Database::class, ['instanceOf' => StaticDatabase::class, 'shared' => true]); ->addRule(Database::class, ['instanceOf' => StaticDatabase::class, 'shared' => true]);
BaseObject::setDependencyInjection($dice); DI::init($dice);
// Default config // Default config
Config::set('config', 'hostname', 'localhost'); Config::set('config', 'hostname', 'localhost');

View file

@ -3,9 +3,9 @@
namespace Friendica\Test\src\Database; namespace Friendica\Test\src\Database;
use Dice\Dice; use Dice\Dice;
use Friendica\BaseObject;
use Friendica\Database\Database; use Friendica\Database\Database;
use Friendica\Database\DBStructure; use Friendica\Database\DBStructure;
use Friendica\DI;
use Friendica\Test\DatabaseTest; use Friendica\Test\DatabaseTest;
use Friendica\Test\Util\Database\StaticDatabase; use Friendica\Test\Util\Database\StaticDatabase;
@ -18,7 +18,7 @@ class DBStructureTest extends DatabaseTest
$dice = (new Dice()) $dice = (new Dice())
->addRules(include __DIR__ . '/../../../static/dependencies.config.php') ->addRules(include __DIR__ . '/../../../static/dependencies.config.php')
->addRule(Database::class, ['instanceOf' => StaticDatabase::class, 'shared' => true]); ->addRule(Database::class, ['instanceOf' => StaticDatabase::class, 'shared' => true]);
BaseObject::setDependencyInjection($dice); DI::init($dice);
} }
/** /**

View file

@ -3,7 +3,7 @@
namespace Friendica\Test\src\Network; namespace Friendica\Test\src\Network;
use Dice\Dice; use Dice\Dice;
use Friendica\BaseObject; use Friendica\DI;
use Friendica\Network\CurlResult; use Friendica\Network\CurlResult;
use Mockery\MockInterface; use Mockery\MockInterface;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
@ -26,7 +26,7 @@ class CurlResultTest extends TestCase
->with(LoggerInterface::class) ->with(LoggerInterface::class)
->andReturn($logger); ->andReturn($logger);
BaseObject::setDependencyInjection($dice); DI::init($dice);
} }
/** /**