Browse Source

Replace BaseObject class with DI::* calls

pull/8019/head
nupplaPhil 2 months ago
parent
commit
388b963714
No account linked to committer's email address
98 changed files with 321 additions and 440 deletions
  1. +1
    -2
      bin/auth_ejabberd.php
  2. +1
    -1
      bin/daemon.php
  3. +1
    -2
      bin/worker.php
  4. +0
    -1
      boot.php
  5. +4
    -12
      include/api.php
  6. +5
    -14
      include/conversation.php
  7. +0
    -5
      include/items.php
  8. +1
    -1
      index.php
  9. +2
    -5
      mod/dfrn_poll.php
  10. +2
    -3
      mod/events.php
  11. +3
    -7
      mod/item.php
  12. +2
    -4
      mod/lockview.php
  13. +3
    -9
      mod/network.php
  14. +2
    -2
      mod/notifications.php
  15. +4
    -8
      mod/photos.php
  16. +2
    -5
      mod/settings.php
  17. +2
    -2
      src/App/Module.php
  18. +1
    -1
      src/BaseModule.php
  19. +0
    -58
      src/BaseObject.php
  20. +1
    -2
      src/Content/Text/BBCode.php
  21. +1
    -2
      src/Content/Text/Markdown.php
  22. +1
    -2
      src/Core/ACL.php
  23. +1
    -2
      src/Core/Addon.php
  24. +7
    -8
      src/Core/Cache.php
  25. +6
    -7
      src/Core/Config.php
  26. +1
    -1
      src/Core/Console.php
  27. +1
    -2
      src/Core/Hook.php
  28. +9
    -9
      src/Core/L10n.php
  29. +6
    -7
      src/Core/Lock.php
  30. +25
    -13
      src/Core/Logger.php
  31. +6
    -7
      src/Core/PConfig.php
  32. +1
    -2
      src/Core/Renderer.php
  33. +1
    -2
      src/Core/Search.php
  34. +12
    -17
      src/Core/Session.php
  35. +2
    -5
      src/Core/System.php
  36. +0
    -1
      src/Core/Theme.php
  37. +0
    -1
      src/Core/Worker.php
  38. +89
    -0
      src/DI.php
  39. +39
    -39
      src/Database/DBA.php
  40. +1
    -2
      src/Model/APContact.php
  41. +1
    -2
      src/Model/Attach.php
  42. +1
    -3
      src/Model/Contact.php
  43. +1
    -2
      src/Model/Event.php
  44. +1
    -2
      src/Model/Group.php
  45. +3
    -7
      src/Model/Item.php
  46. +1
    -2
      src/Model/ItemContent.php
  47. +1
    -2
      src/Model/ItemURI.php
  48. +1
    -2
      src/Model/Nodeinfo.php
  49. +1
    -2
      src/Model/Notify.php
  50. +1
    -2
      src/Model/PermissionSet.php
  51. +1
    -2
      src/Model/Photo.php
  52. +1
    -2
      src/Model/Process.php
  53. +1
    -2
      src/Model/Search.php
  54. +1
    -2
      src/Model/TwoFactor/AppSpecificPassword.php
  55. +1
    -2
      src/Model/TwoFactor/RecoveryCode.php
  56. +1
    -2
      src/Module/Admin/Summary.php
  57. +2
    -3
      src/Module/Api/Mastodon/FollowRequests.php
  58. +4
    -4
      src/Module/Base/Api.php
  59. +1
    -2
      src/Module/BaseSearchModule.php
  60. +1
    -4
      src/Module/Delegation.php
  61. +5
    -10
      src/Module/Diaspora/Receive.php
  62. +1
    -2
      src/Module/Item/Compose.php
  63. +3
    -6
      src/Module/Item/Ignore.php
  64. +2
    -7
      src/Module/Notifications/Notify.php
  65. +1
    -4
      src/Module/Profile.php
  66. +1
    -1
      src/Module/Register.php
  67. +1
    -3
      src/Module/Search/Index.php
  68. +1
    -5
      src/Module/Search/Saved.php
  69. +2
    -7
      src/Module/Security/Login.php
  70. +1
    -4
      src/Module/Security/TwoFactor/Recovery.php
  71. +1
    -3
      src/Module/Security/TwoFactor/Verify.php
  72. +1
    -2
      src/Module/Settings/Delegation.php
  73. +1
    -1
      src/Module/Settings/UserExport.php
  74. +1
    -6
      src/Network/FKOAuth1.php
  75. +3
    -9
      src/Object/Post.php
  76. +1
    -2
      src/Object/Thread.php
  77. +0
    -1
      src/Protocol/ActivityPub/Transmitter.php
  78. +2
    -5
      src/Protocol/DFRN.php
  79. +0
    -1
      src/Util/Images.php
  80. +0
    -1
      src/Util/Proxy.php
  81. +1
    -2
      src/Util/Security.php
  82. +1
    -2
      src/Worker/APDelivery.php
  83. +0
    -1
      src/Worker/Cron.php
  84. +0
    -1
      src/Worker/CronJobs.php
  85. +1
    -2
      src/Worker/DBUpdate.php
  86. +1
    -2
      src/Worker/Delivery.php
  87. +0
    -1
      src/Worker/Expire.php
  88. +1
    -3
      src/Worker/Notifier.php
  89. +0
    -2
      src/Worker/OnePoll.php
  90. +0
    -1
      src/Worker/ProfileUpdate.php
  91. +2
    -2
      tests/Util/AppMockTrait.php
  92. +2
    -4
      tests/include/ApiTest.php
  93. +2
    -2
      tests/src/Console/AutomaticInstallationConsoleTest.php
  94. +2
    -3
      tests/src/Core/InstallerTest.php
  95. +2
    -2
      tests/src/Core/Lock/SemaphoreLockTest.php
  96. +2
    -2
      tests/src/Database/DBATest.php
  97. +2
    -2
      tests/src/Database/DBStructureTest.php
  98. +2
    -2
      tests/src/Network/CurlResultTest.php

+ 1
- 2
bin/auth_ejabberd.php View File

@@ -34,7 +34,6 @@

use Dice\Dice;
use Friendica\App\Mode;
use Friendica\BaseObject;
use Friendica\Util\ExAuth;
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 = $dice->addRule(LoggerInterface::class,['constructParams' => ['auth_ejabberd']]);

BaseObject::setDependencyInjection($dice);
\Friendica\DI::init($dice);

$appMode = $dice->create(Mode::class);


+ 1
- 1
bin/daemon.php View File

@@ -36,7 +36,7 @@ require dirname(__DIR__) . '/vendor/autoload.php';
$dice = (new Dice())->addRules(include __DIR__ . '/../static/dependencies.config.php');
$dice = $dice->addRule(LoggerInterface::class,['constructParams' => ['daemon']]);

\Friendica\BaseObject::setDependencyInjection($dice);
\Friendica\DI::init($dice);
$a = \Friendica\DI::app();

if ($a->getMode()->isInstall()) {

+ 1
- 2
bin/worker.php View File

@@ -7,7 +7,6 @@

use Dice\Dice;
use Friendica\App;
use Friendica\BaseObject;
use Friendica\Core\Config;
use Friendica\Core\Update;
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 = $dice->addRule(LoggerInterface::class,['constructParams' => ['worker']]);

BaseObject::setDependencyInjection($dice);
\Friendica\DI::init($dice);
$a = Friendica\DI::app();

// Check the database structure and possibly fixes it

+ 0
- 1
boot.php View File

@@ -18,7 +18,6 @@
*/

use Friendica\App;
use Friendica\BaseObject;
use Friendica\Core\Config;
use Friendica\Core\PConfig;
use Friendica\Core\Protocol;

+ 4
- 12
include/api.php View File

@@ -7,12 +7,10 @@
*/

use Friendica\App;
use Friendica\BaseObject;
use Friendica\Content\ContactSelector;
use Friendica\Content\Feature;
use Friendica\Content\Text\BBCode;
use Friendica\Content\Text\HTML;
use Friendica\App\Authentication;
use Friendica\Core\Config;
use Friendica\Core\Hook;
use Friendica\Core\L10n;
@@ -23,11 +21,11 @@ use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\Core\Worker;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\Group;
use Friendica\Model\Item;
use Friendica\Model\Mail;
use Friendica\Model\Notify;
use Friendica\Model\Photo;
use Friendica\Model\Profile;
use Friendica\Model\User;
@@ -254,9 +252,7 @@ function api_login(App $a)
throw new UnauthorizedException("This API requires login");
}

/** @var Authentication $authentication */
$authentication = BaseObject::getClass(Authentication::class);
$authentication->setForUser($a, $record);
DI::auth()->setForUser($a, $record);

$_SESSION["allow_api"] = true;

@@ -5909,10 +5905,7 @@ function api_friendica_notification($type)
if ($a->argc!==3) {
throw new BadRequestException("Invalid argument count");
}
/** @var Notify $nm */
$nm = BaseObject::getClass(Notify::class);

$notes = $nm->getAll([], ['seen' => 'ASC', 'date' => 'DESC'], 50);
$notes = DI::notify()->getAll([], ['seen' => 'ASC', 'date' => 'DESC'], 50);

if ($type == "xml") {
$xmlnotes = [];
@@ -5954,8 +5947,7 @@ function api_friendica_notification_seen($type)

$id = (!empty($_REQUEST['id']) ? intval($_REQUEST['id']) : 0);

/** @var Notify $nm */
$nm = BaseObject::getClass(Notify::class);
$nm = DI::notify();
$note = $nm->getByID($id);
if (is_null($note)) {
throw new BadRequestException("Invalid argument");

+ 5
- 14
include/conversation.php View File

@@ -4,10 +4,8 @@
*/

use Friendica\App;
use Friendica\BaseObject;
use Friendica\Content\ContactSelector;
use Friendica\Content\Feature;
use Friendica\Content\Item as ContentItem;
use Friendica\Content\Pager;
use Friendica\Content\Text\BBCode;
use Friendica\Core\Config;
@@ -20,6 +18,7 @@ use Friendica\Core\Renderer;
use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\Item;
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.
*/

/** @var Activity $activity */
$activity = BaseObject::getClass(Activity::class);
$activity = DI::activity();

$xmlhead = "<" . "?xml version='1.0' encoding='UTF-8' ?" . ">";
if ($activity->match($item['verb'], Activity::LIKE)
@@ -399,8 +397,7 @@ function count_descendants($item) {

function visible_activity($item) {

/** @var Activity $activity */
$activity = BaseObject::getClass(Activity::class);
$activity = DI::activity();

if (empty($item['verb']) || $activity->isHidden($item['verb'])) {
return false;
@@ -668,10 +665,7 @@ function conversation(App $a, array $items, Pager $pager, $mode, $update, $previ

$body = Item::prepareBody($item, true, $preview);

/** @var ContentItem $contItem */
$contItem = BaseObject::getClass(ContentItem::class);

list($categories, $folders) = $contItem->determineCategoriesTerms($item);
list($categories, $folders) = DI::contentItem()->determineCategoriesTerms($item);

if (!empty($item['content-warning']) && PConfig::get(local_user(), 'system', 'disable_cw', false)) {
$title = ucfirst($item['content-warning']);
@@ -1031,10 +1025,7 @@ function builtin_activity_puller($item, &$conv_responses) {
return;
}

/** @var Activity $activity */
$activity = BaseObject::getClass(Activity::class);

if (!empty($item['verb']) && $activity->match($item['verb'], $verb) && ($item['id'] != $item['parent'])) {
if (!empty($item['verb']) && DI::activity()->match($item['verb'], $verb) && ($item['id'] != $item['parent'])) {
$author = ['uid' => 0, 'id' => $item['author-id'],
'network' => $item['author-network'], 'url' => $item['author-link']];
$url = Contact::magicLinkByContact($author);

+ 0
- 5
include/items.php View File

@@ -3,13 +3,10 @@
* @file include/items.php
*/

use Friendica\BaseObject;
use Friendica\Content\Feature;
use Friendica\Core\Config;
use Friendica\Core\Hook;
use Friendica\Core\L10n;
use Friendica\Core\Logger;
use Friendica\Core\PConfig;
use Friendica\Core\Protocol;
use Friendica\Core\Renderer;
use Friendica\Core\System;
@@ -19,11 +16,9 @@ use Friendica\Model\Item;
use Friendica\Protocol\DFRN;
use Friendica\Protocol\Feed;
use Friendica\Protocol\OStatus;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Network;
use Friendica\Util\ParseUrl;
use Friendica\Util\Strings;
use Friendica\Util\Temporal;

require_once __DIR__ . '/../mod/share.php';


+ 1
- 1
index.php View File

@@ -15,7 +15,7 @@ require __DIR__ . '/vendor/autoload.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]]]);

\Friendica\BaseObject::setDependencyInjection($dice);
\Friendica\DI::init($dice);

$a = \Friendica\DI::app();


+ 2
- 5
mod/dfrn_poll.php View File

@@ -5,14 +5,13 @@
*/

use Friendica\App;
use Friendica\BaseObject;
use Friendica\App\Authentication;
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\Logger;
use Friendica\Core\System;
use Friendica\Core\Session;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Module\Security\Login;
use Friendica\Protocol\DFRN;
use Friendica\Protocol\OStatus;
@@ -22,9 +21,7 @@ use Friendica\Util\XML;

function dfrn_poll_init(App $a)
{
/** @var Authentication $authentication */
$authentication = BaseObject::getClass(Authentication::class);
$authentication->withSession($a);
DI::auth()->withSession($a);

$dfrn_id = $_GET['dfrn_id'] ?? '';
$type = ($_GET['type'] ?? '') ?: 'data';

+ 2
- 3
mod/events.php View File

@@ -5,7 +5,6 @@
*/

use Friendica\App;
use Friendica\BaseObject;
use Friendica\Content\Nav;
use Friendica\Content\Widget\CalendarExport;
use Friendica\Core\ACL;
@@ -19,6 +18,7 @@ use Friendica\Database\DBA;
use Friendica\Model\Event;
use Friendica\Model\Item;
use Friendica\Model\Profile;
use Friendica\Module\Login;
use Friendica\Module\Security\Login;
use Friendica\Util\ACLFormatter;
use Friendica\Util\DateTimeFormat;
@@ -150,8 +150,7 @@ function events_post(App $a)

if ($share) {

/** @var ACLFormatter $aclFormatter */
$aclFormatter = BaseObject::getClass(ACLFormatter::class);
$aclFormatter = \Friendica\DI::aclFormatter();

$str_group_allow = $aclFormatter->toString($_POST['group_allow'] ?? '');
$str_contact_allow = $aclFormatter->toString($_POST['contact_allow'] ?? '');

+ 3
- 7
mod/item.php View File

@@ -16,7 +16,6 @@
*/

use Friendica\App;
use Friendica\BaseObject;
use Friendica\Content\Pager;
use Friendica\Content\Text\BBCode;
use Friendica\Content\Text\HTML;
@@ -29,6 +28,7 @@ use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\Core\Worker;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Attach;
use Friendica\Model\Contact;
use Friendica\Model\Conversation;
@@ -39,7 +39,6 @@ use Friendica\Model\Term;
use Friendica\Protocol\Activity;
use Friendica\Protocol\Diaspora;
use Friendica\Protocol\Email;
use Friendica\Util\ACLFormatter;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Emailer;
use Friendica\Util\Security;
@@ -273,8 +272,7 @@ function item_post(App $a) {
} else {
// use the posted permissions

/** @var ACLFormatter $aclFormatter */
$aclFormatter = BaseObject::getClass(ACLFormatter::class);
$aclFormatter = DI::aclFormatter();

$str_group_allow = $aclFormatter->toString($_REQUEST['group_allow'] ?? '');
$str_contact_allow = $aclFormatter->toString($_REQUEST['contact_allow'] ?? '');
@@ -506,9 +504,7 @@ function item_post(App $a) {
$objecttype = Activity\ObjectType::BOOKMARK;
}

/** @var BBCode\Video $bbCodeVideo */
$bbCodeVideo = BaseObject::getClass(BBCode\Video::class);
$body = $bbCodeVideo->transform($body);
$body = DI::bbCodeVideo()->transform($body);

// Fold multi-line [code] sequences
$body = preg_replace('/\[\/code\]\s*\[code\]/ism', "\n", $body);

+ 2
- 4
mod/lockview.php View File

@@ -3,13 +3,12 @@
* @file mod/lockview.php
*/
use Friendica\App;
use Friendica\BaseObject;
use Friendica\Core\Hook;
use Friendica\Core\L10n;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Group;
use Friendica\Model\Item;
use Friendica\Util\ACLFormatter;

function lockview_content(App $a)
{
@@ -61,8 +60,7 @@ function lockview_content(App $a)
exit();
}

/** @var ACLFormatter $aclFormatter */
$aclFormatter = BaseObject::getClass(ACLFormatter::class);
$aclFormatter = DI::aclFormatter();

$allowed_users = $aclFormatter->expand($item['allow_cid']);
$allowed_groups = $aclFormatter->expand($item['allow_gid']);

+ 3
- 9
mod/network.php View File

@@ -5,7 +5,6 @@
*/

use Friendica\App;
use Friendica\BaseObject;
use Friendica\Content\Feature;
use Friendica\Content\ForumManager;
use Friendica\Content\Nav;
@@ -22,6 +21,7 @@ use Friendica\Core\Protocol;
use Friendica\Core\Renderer;
use Friendica\Core\Session;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\Group;
use Friendica\Model\Item;
@@ -52,12 +52,9 @@ function network_init(App $a)
$group_id = 0;
}

/** @var DateTimeFormat $dtFormat */
$dtFormat = BaseObject::getClass(DateTimeFormat::class);

if ($a->argc > 1) {
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;
break;
}
@@ -465,12 +462,9 @@ function networkThreadedView(App $a, $update, $parent)

$default_permissions = [];

/** @var DateTimeFormat $dtFormat */
$dtFormat = BaseObject::getClass(DateTimeFormat::class);

if ($a->argc > 1) {
for ($x = 1; $x < $a->argc; $x ++) {
if ($dtFormat->isYearMonth($a->argv[$x])) {
if (DI::dtFormat()->isYearMonth($a->argv[$x])) {
if ($datequery) {
$datequery2 = Strings::escapeHtml($a->argv[$x]);
} else {

+ 2
- 2
mod/notifications.php View File

@@ -13,6 +13,7 @@ use Friendica\Core\Protocol;
use Friendica\Core\Renderer;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Module\Security\Login;
use Friendica\Model\Introduction;
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);

/** @var Notify $nm */
$nm = \Friendica\BaseObject::getClass(Notify::class);
$nm = DI::notify();

$o = '';
// Get the nav tabs for the notification pages

+ 4
- 8
mod/photos.php View File

@@ -4,7 +4,6 @@
*/

use Friendica\App;
use Friendica\BaseObject;
use Friendica\Content\Feature;
use Friendica\Content\Nav;
use Friendica\Content\Pager;
@@ -18,6 +17,7 @@ use Friendica\Core\Renderer;
use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\Item;
use Friendica\Model\Photo;
@@ -26,7 +26,6 @@ use Friendica\Model\User;
use Friendica\Network\Probe;
use Friendica\Object\Image;
use Friendica\Protocol\Activity;
use Friendica\Util\ACLFormatter;
use Friendica\Util\Crypto;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Images;
@@ -298,8 +297,7 @@ function photos_post(App $a)
$albname = !empty($_POST['albname']) ? Strings::escapeTags(trim($_POST['albname'])) : '';
$origaname = !empty($_POST['origaname']) ? Strings::escapeTags(trim($_POST['origaname'])) : '';

/** @var ACLFormatter $aclFormatter */
$aclFormatter = BaseObject::getClass(ACLFormatter::class);
$aclFormatter = DI::aclFormatter();

$str_group_allow = !empty($_POST['group_allow']) ? $aclFormatter->toString($_POST['group_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'] ?? [];
$contact_deny = $_REQUEST['contact_deny'] ?? [];

/** @var ACLFormatter $aclFormatter */
$aclFormatter = BaseObject::getClass(ACLFormatter::class);
$aclFormatter = DI::aclFormatter();

$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));
@@ -1442,8 +1439,7 @@ function photos_content(App $a)
$template = $tpl;
$sparkle = '';

/** @var Activity $activity */
$activity = BaseObject::getClass(Activity::class);
$activity = DI::activity();

if (($activity->match($item['verb'], Activity::LIKE) ||
$activity->match($item['verb'], Activity::DISLIKE)) &&

+ 2
- 5
mod/settings.php View File

@@ -5,7 +5,6 @@

use Friendica\App;
use Friendica\BaseModule;
use Friendica\BaseObject;
use Friendica\Content\Feature;
use Friendica\Content\Nav;
use Friendica\Core\ACL;
@@ -20,14 +19,13 @@ use Friendica\Core\System;
use Friendica\Core\Theme;
use Friendica\Core\Worker;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\GContact;
use Friendica\Model\Group;
use Friendica\Model\User;
use Friendica\Module\Security\Login;
use Friendica\Protocol\Email;
use Friendica\Util\ACLFormatter;
use Friendica\Util\Network;
use Friendica\Util\Strings;
use Friendica\Util\Temporal;
use Friendica\Worker\Delivery;
@@ -564,8 +562,7 @@ function settings_post(App $a)
date_default_timezone_set($timezone);
}

/** @var ACLFormatter $aclFormatter */
$aclFormatter = BaseObject::getClass(ACLFormatter::class);
$aclFormatter = DI::aclFormatter();

$str_group_allow = !empty($_POST['group_allow']) ? $aclFormatter->toString($_POST['group_allow']) : '';
$str_contact_allow = !empty($_POST['contact_allow']) ? $aclFormatter->toString($_POST['contact_allow']) : '';

+ 2
- 2
src/App/Module.php View File

@@ -3,7 +3,7 @@
namespace Friendica\App;

use Friendica\App;
use Friendica\BaseObject;
use Friendica\BaseModule;
use Friendica\Core;
use Friendica\LegacyModule;
use Friendica\Module\Home;
@@ -59,7 +59,7 @@ class Module
private $module;

/**
* @var BaseObject The module class
* @var BaseModule The module class
*/
private $module_class;


+ 1
- 1
src/BaseModule.php View File

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

+ 0
- 58
src/BaseObject.php 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.');
}
}
}

+ 1
- 2
src/Content/Text/BBCode.php View File

@@ -8,7 +8,6 @@ namespace Friendica\Content\Text;
use DOMDocument;
use DOMXPath;
use Exception;
use Friendica\BaseObject;
use Friendica\Content\OEmbed;
use Friendica\Content\Smilies;
use Friendica\Core\Cache;
@@ -34,7 +33,7 @@ use Friendica\Util\Proxy as ProxyUtils;
use Friendica\Util\Strings;
use Friendica\Util\XML;

class BBCode extends BaseObject
class BBCode
{
/**
* @brief Fetches attachment data that were generated the old way

+ 1
- 2
src/Content/Text/Markdown.php View File

@@ -6,7 +6,6 @@

namespace Friendica\Content\Text;

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

+ 1
- 2
src/Core/ACL.php View File

@@ -7,7 +7,6 @@
namespace Friendica\Core;

use Friendica\App\Page;
use Friendica\BaseObject;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact;
@@ -18,7 +17,7 @@ use Friendica\Model\Group;
*
* @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

+ 1
- 2
src/Core/Addon.php View File

@@ -5,7 +5,6 @@

namespace Friendica\Core;

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

+ 7
- 8
src/Core/Cache.php View File

@@ -4,14 +4,13 @@
*/
namespace Friendica\Core;

use Friendica\BaseObject;
use Friendica\Core\Cache\Cache as CacheClass;
use Friendica\Core\Cache\ICache;
use Friendica\DI;

/**
* @brief Class for storing data for a short time
*/
class Cache extends BaseObject
class Cache
{
/** @deprecated Use CacheClass::MONTH */
const MONTH = CacheClass::MONTH;
@@ -42,7 +41,7 @@ class Cache extends BaseObject
*/
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)
{
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)
{
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)
{
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)
{
return self::getClass(ICache::class)->clear($outdated);
return DI::cache()->clear($outdated);
}
}

+ 6
- 7
src/Core/Config.php View File

@@ -8,8 +8,7 @@
*/
namespace Friendica\Core;

use Friendica\BaseObject;
use Friendica\Core\Config\Configuration;
use Friendica\DI;

/**
* @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,
* 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.
@@ -29,7 +28,7 @@ class Config extends BaseObject
*/
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)
{
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)
{
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)
{
return self::getClass(Configuration::class)->delete($cat, $key);
return DI::config()->delete($cat, $key);
}
}

+ 1
- 1
src/Core/Console.php View File

@@ -146,7 +146,7 @@ HELP;

$className = $this->subConsoles[$command];

Friendica\BaseObject::setDependencyInjection($this->dice);
Friendica\DI::init($this->dice);

/** @var Console $subconsole */
$subconsole = $this->dice->create($className, [$subargs]);

+ 1
- 2
src/Core/Hook.php View File

@@ -5,7 +5,6 @@
namespace Friendica\Core;

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

+ 9
- 9
src/Core/L10n.php View File

@@ -4,14 +4,14 @@
*/
namespace Friendica\Core;

use Friendica\BaseObject;
use Friendica\Core\L10n\L10n as L10nClass;
use Friendica\DI;

/**
* 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").
*/
class L10n extends BaseObject
class L10n
{
/**
* Returns the current language code
@@ -20,7 +20,7 @@ class L10n extends BaseObject
*/
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)
{
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)
{
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)
{
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)
{
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)
{
return self::getClass(L10nClass::class)->getDayShort($s);
return DI::l10n()->getDayShort($s);
}

/**
@@ -131,6 +131,6 @@ class L10n extends BaseObject
*/
public static function getPokeVerbs()
{
return self::getClass(L10nClass::class)->getPokeVerbs();
return DI::l10n()->getPokeVerbs();
}
}

+ 6
- 7
src/Core/Lock.php View File

@@ -7,14 +7,13 @@

namespace Friendica\Core;

use Friendica\BaseObject;
use Friendica\Core\Cache\Cache;
use Friendica\Core\Lock\ILock;
use Friendica\DI;

/**
* This class contain Functions for preventing parallel execution of functions
*/
class Lock extends BaseObject
class Lock
{
/**
* @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)
{
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 bool $override Overrides the lock to get releases
*
* @return void
* @return bool
* @throws \Exception
*/
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()
{
self::getClass(ILock::class)->releaseAll();
DI::lock()->releaseAll();
}
}

+ 25
- 13
src/Core/Logger.php View File

@@ -4,7 +4,7 @@
*/
namespace Friendica\Core;

use Friendica\BaseObject;
use Friendica\DI;
use Friendica\Util\Logger\WorkerLogger;
use Psr\Log\LoggerInterface;
use Psr\Log\LogLevel;
@@ -12,7 +12,7 @@ use Psr\Log\LogLevel;
/**
* @brief Logger functions
*/
class Logger extends BaseObject
class Logger
{
/**
* @see Logger::error()
@@ -66,6 +66,18 @@ class Logger extends BaseObject
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
*
@@ -76,7 +88,7 @@ class Logger extends BaseObject
public static function enableWorker(string $functionName)
{
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 = [])
{
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 = [])
{
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 = [])
{
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 = [])
{
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 = [])
{
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 = [])
{
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 = [])
{
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 = [])
{
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)
{
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)
{
self::getClass('$devLogger')->log($level, $msg);
DI::devLogger()->log($level, $msg);
}
}

+ 6
- 7
src/Core/PConfig.php View File

@@ -8,8 +8,7 @@
*/
namespace Friendica\Core;

use Friendica\BaseObject;
use Friendica\Core\Config\PConfiguration;
use Friendica\DI;

/**
* @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,
* 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.
@@ -30,7 +29,7 @@ class PConfig extends BaseObject
*/
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)
{
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)
{
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)
{
return self::getClass(PConfiguration::class)->delete($uid, $cat, $key);
return DI::pConfig()->delete($uid, $cat, $key);
}
}

+ 1
- 2
src/Core/Renderer.php View File

@@ -6,7 +6,6 @@
namespace Friendica\Core;

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

+ 1
- 2
src/Core/Search.php View File

@@ -2,7 +2,6 @@

namespace Friendica\Core;

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


+ 12
- 17
src/Core/Session.php View File

@@ -5,9 +5,8 @@
*/
namespace Friendica\Core;

use Friendica\BaseObject;
use Friendica\Core\Session\ISession;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Util\Strings;

@@ -16,39 +15,39 @@ use Friendica\Util\Strings;
*
* @author Hypolite Petovan <hypolite@mrpetovan.com>
*/
class Session extends BaseObject
class Session
{
public static $exists = false;
public static $expire = 180000;

public static function exists($name)
{
return self::getClass(ISession::class)->exists($name);
return DI::session()->exists($name);
}

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)
{
self::getClass(ISession::class)->set($name, $value);
DI::session()->set($name, $value);
}

public static function setMultiple(array $values)
{
self::getClass(ISession::class)->setMultiple($values);
DI::session()->setMultiple($values);
}

public static function remove($name)
{
self::getClass(ISession::class)->remove($name);
DI::session()->remove($name);
}

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)
{
/** @var ISession $session */
$session = self::getClass(ISession::class);
$session = DI::session();

if (empty($session->get('remote')[$uid])) {
return false;
@@ -77,8 +75,7 @@ class Session extends BaseObject
*/
public static function getUserIDForVisitorContactID($cid)
{
/** @var ISession $session */
$session = self::getClass(ISession::class);
$session = DI::session();

if (empty($session->get('remote'))) {
return false;
@@ -94,8 +91,7 @@ class Session extends BaseObject
*/
public static function setVisitorsContacts()
{
/** @var ISession $session */
$session = self::getClass(ISession::class);
$session = DI::session();

$session->set('remote', []);

@@ -117,8 +113,7 @@ class Session extends BaseObject
*/
public static function isAuthenticated()
{
/** @var ISession $session */
$session = self::getClass(ISession::class);
$session = DI::session();

return $session->get('authenticated', false);
}

+ 2
- 5
src/Core/System.php View File

@@ -4,8 +4,6 @@
*/
namespace Friendica\Core;

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

/**

+ 0
- 1
src/Core/Theme.php View File

@@ -6,7 +6,6 @@

namespace Friendica\Core;

use Friendica\BaseObject;
use Friendica\DI;
use Friendica\Model\Profile;
use Friendica\Util\Strings;

+ 0
- 1
src/Core/Worker.php View File

@@ -4,7 +4,6 @@
*/
namespace Friendica\Core;

use Friendica\BaseObject;
use Friendica\Core;
use Friendica\Database\DBA;
use Friendica\DI;

+ 89
- 0
src/DI.php View File

@@ -3,6 +3,22 @@
namespace Friendica;

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
@@ -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
*
* @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
{
@@ -26,6 +67,54 @@ class DI
switch ($name) {
case 'app':
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:
return null;
}

+ 39
- 39
src/Database/DBA.php View File

@@ -2,7 +2,7 @@

namespace Friendica\Database;

use Friendica\BaseObject;
use Friendica\DI;
use mysqli;
use mysqli_result;
use mysqli_stmt;
@@ -14,7 +14,7 @@ use PDOStatement;
*
* This class is for the low level database stuff that does driver specific things.
*/
class DBA extends BaseObject
class DBA
{
/**
* Lowest possible date value
@@ -27,7 +27,7 @@ class DBA extends BaseObject

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()
{
self::getClass(Database::class)->disconnect();
DI::dba()->disconnect();
}

/**
@@ -43,7 +43,7 @@ class DBA extends BaseObject
*/
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()
{
return self::getClass(Database::class)->getConnection();
return DI::dba()->getConnection();
}

/**
@@ -65,7 +65,7 @@ class DBA extends BaseObject
*/
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()
{
return self::getClass(Database::class)->databaseName();
return DI::dba()->databaseName();
}

public static function escape($str)
{
return self::getClass(Database::class)->escape($str);
return DI::dba()->escape($str);
}

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)
{
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());

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());

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)
{
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());

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()
{
return self::getClass(Database::class)->affectedRows();
return DI::dba()->affectedRows();
}

/**
@@ -226,7 +226,7 @@ class DBA extends BaseObject
*/
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
@@ -236,7 +236,7 @@ class DBA extends BaseObject
*/
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)
{
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)
{
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()
{
return self::getClass(Database::class)->lastInsertId();
return DI::dba()->lastInsertId();
}

/**
@@ -287,7 +287,7 @@ class DBA extends BaseObject
*/
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()
{
return self::getClass(Database::class)->unlock();
return DI::dba()->unlock();
}

/**
@@ -308,7 +308,7 @@ class DBA extends BaseObject
*/
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()
{
return self::getClass(Database::class)->commit();
return DI::dba()->commit();
}

/**
@@ -328,7 +328,7 @@ class DBA extends BaseObject
*/
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 = [])
{
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 = [])
{
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 = [])
{
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 = [])
{
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 = [])
{
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 = [])
{
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)
{
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()
{
return self::getClass(Database::class)->errorNo();
return DI::dba()->errorNo();
}

/**
@@ -659,7 +659,7 @@ class DBA extends BaseObject
*/
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)
{
return self::getClass(Database::class)->close($stmt);
return DI::dba()->close($stmt);
}

/**
@@ -683,7 +683,7 @@ class DBA extends BaseObject
*/
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)
{
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)
{
return self::getClass(Database::class)->escapeArray($arr, $add_quotation);
DI::dba()->escapeArray($arr, $add_quotation);
}
}

+ 1
- 2
src/Model/APContact.php View File

@@ -6,7 +6,6 @@

namespace Friendica\Model;

use Friendica\BaseObject;
use Friendica\Content\Text\HTML;
use Friendica\Core\Logger;
use Friendica\Core\Config;
@@ -17,7 +16,7 @@ use Friendica\Util\JsonLD;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Strings;

class APContact extends BaseObject
class APContact
{
/**
* Resolves the profile url from the address by using webfinger

+ 1
- 2
src/Model/Attach.php View File

@@ -6,7 +6,6 @@
*/
namespace Friendica\Model;

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

/**

+ 1
- 3
src/Model/Contact.php View File

@@ -5,7 +5,6 @@
namespace Friendica\Model;

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

+ 1
- 2
src/Model/Event.php View File

@@ -5,7 +5,6 @@

namespace Friendica\Model;

use Friendica\BaseObject;
use Friendica\Content\Text\BBCode;
use Friendica\Core\Hook;
use Friendica\Core\L10n;
@@ -23,7 +22,7 @@ use Friendica\Util\XML;
/**
* @brief functions for interacting with the event database table
*/
class Event extends BaseObject
class Event
{

public static function getHTML(array $event, $simple = false)

+ 1
- 2
src/Model/Group.php View File

@@ -6,7 +6,6 @@
namespace Friendica\Model;

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

+ 3
- 7
src/Model/Item.php View File

@@ -6,7 +6,6 @@

namespace Friendica\Model;

use Friendica\BaseObject;
use Friendica\Content\Text\BBCode;
use Friendica\Content\Text\HTML;
use Friendica\Core\Config;
@@ -26,7 +25,6 @@ use Friendica\Protocol\Activity;
use Friendica\Protocol\ActivityPub;
use Friendica\Protocol\Diaspora;
use Friendica\Protocol\OStatus;
use Friendica\Util\ACLFormatter;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Map;
use Friendica\Util\Network;
@@ -36,7 +34,7 @@ use Friendica\Util\XML;
use Friendica\Worker\Delivery;
use Text_LanguageDetect;

class Item extends BaseObject
class Item
{
// Posting types, inspired by https://www.w3.org/TR/activitystreams-vocabulary/#object-types
const PT_ARTICLE = 0;
@@ -1442,8 +1440,7 @@ class Item extends BaseObject
$item['parent-uri'] = $item['thr-parent'];
}

/** @var Activity $activity */
$activity = self::getClass(Activity::class);
$activity = DI::activity();

if (isset($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)
{
/** @var ACLFormatter $aclFormater */
$aclFormater = self::getClass(ACLFormatter::class);
$aclFormater = DI::aclFormatter();

$allow_people = $aclFormater->expand($obj['allow_cid']);
$allow_groups = Group::expand($obj['uid'], $aclFormater->expand($obj['allow_gid']), $check_dead);

+ 1
- 2
src/Model/ItemContent.php View File

@@ -6,12 +6,11 @@

namespace Friendica\Model;

use Friendica\BaseObject;
use Friendica\Content\Text;
use Friendica\Core\PConfig;
use Friendica\Core\Protocol;

class ItemContent extends BaseObject
class ItemContent
{
/**
* @brief Convert a message into plaintext for connectors to other networks

+ 1
- 2
src/Model/ItemURI.php View File

@@ -6,10 +6,9 @@

namespace Friendica\Model;

use Friendica\BaseObject;
use Friendica\Database\DBA;

class ItemURI extends BaseObject
class ItemURI
{
/**
* @brief Insert an item-uri record and return its id

+ 1
- 2
src/Model/Nodeinfo.php View File

@@ -2,7 +2,6 @@

namespace Friendica\Model;

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

+ 1
- 2
src/Model/Notify.php View File

@@ -4,7 +4,6 @@ namespace Friendica\Model;

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

+ 1
- 2
src/Model/PermissionSet.php View File

@@ -4,13 +4,12 @@
*/
namespace Friendica\Model;

use Friendica\BaseObject;
use Friendica\Database\DBA;