Browse Source

Introduce new DI container

- Adding Friendica\DI class for getting dynamic classes
- Replacing BaseObject::getApp() with this class
pull/8019/head
nupplaPhil 2 years ago
parent
commit
1de3f186d7
No known key found for this signature in database GPG Key ID: D8365C3D36B77D90
  1. 2
      bin/daemon.php
  2. 2
      bin/worker.php
  3. 6
      boot.php
  4. 6
      include/api.php
  5. 2
      include/items.php
  6. 2
      index.php
  7. 13
      src/BaseObject.php
  8. 2
      src/Console/PostUpdate.php
  9. 9
      src/Content/Text/BBCode.php
  10. 3
      src/Content/Text/Markdown.php
  11. 5
      src/Core/ACL.php
  12. 9
      src/Core/Addon.php
  13. 9
      src/Core/Hook.php
  14. 5
      src/Core/Renderer.php
  15. 5
      src/Core/Search.php
  16. 5
      src/Core/System.php
  17. 5
      src/Core/Theme.php
  18. 5
      src/Core/Worker.php
  19. 33
      src/DI.php
  20. 2
      src/LegacyModule.php
  21. 3
      src/Model/Attach.php
  22. 3
      src/Model/Contact.php
  23. 9
      src/Model/Item.php
  24. 3
      src/Model/Nodeinfo.php
  25. 5
      src/Model/Notify.php
  26. 3
      src/Model/Photo.php
  27. 5
      src/Module/Admin/Addons/Details.php
  28. 3
      src/Module/Admin/Addons/Index.php
  29. 5
      src/Module/Admin/Blocklist/Contact.php
  30. 5
      src/Module/Admin/Blocklist/Server.php
  31. 3
      src/Module/Admin/DBSync.php
  32. 3
      src/Module/Admin/Features.php
  33. 3
      src/Module/Admin/Item/Delete.php
  34. 3
      src/Module/Admin/Item/Source.php
  35. 5
      src/Module/Admin/Logs/Settings.php
  36. 3
      src/Module/Admin/Queue.php
  37. 5
      src/Module/Admin/Site.php
  38. 5
      src/Module/Admin/Summary.php
  39. 5
      src/Module/Admin/Themes/Details.php
  40. 7
      src/Module/Admin/Themes/Embed.php
  41. 3
      src/Module/Admin/Themes/Index.php
  42. 3
      src/Module/Admin/Tos.php
  43. 5
      src/Module/Admin/Users.php
  44. 3
      src/Module/AllFriends.php
  45. 3
      src/Module/Apps.php
  46. 3
      src/Module/Attach.php
  47. 7
      src/Module/Base/Api.php
  48. 3
      src/Module/BaseAdminModule.php
  49. 5
      src/Module/BaseSearchModule.php
  50. 3
      src/Module/BaseSettingsModule.php
  51. 3
      src/Module/Bookmarklet.php
  52. 5
      src/Module/Contact.php
  53. 3
      src/Module/Debug/Feed.php
  54. 3
      src/Module/Debug/ItemBody.php
  55. 5
      src/Module/Debug/Localtime.php
  56. 11
      src/Module/Delegation.php
  57. 3
      src/Module/Diaspora/Fetch.php
  58. 3
      src/Module/Directory.php
  59. 3
      src/Module/Feed.php
  60. 3
      src/Module/Filer/RemoveTag.php
  61. 5
      src/Module/Filer/SaveTag.php
  62. 3
      src/Module/FollowConfirm.php
  63. 3
      src/Module/Followers.php
  64. 3
      src/Module/Following.php
  65. 5
      src/Module/Friendica.php
  66. 7
      src/Module/Group.php
  67. 3
      src/Module/Help.php
  68. 3
      src/Module/Home.php
  69. 3
      src/Module/Inbox.php
  70. 7
      src/Module/Install.php
  71. 5
      src/Module/Invite.php
  72. 5
      src/Module/Item/Compose.php
  73. 3
      src/Module/Item/Ignore.php
  74. 3
      src/Module/Like.php
  75. 5
      src/Module/Magic.php
  76. 3
      src/Module/Maintenance.php
  77. 3
      src/Module/Manifest.php
  78. 3
      src/Module/NodeInfo.php
  79. 5
      src/Module/Notifications/Notify.php
  80. 3
      src/Module/Objects.php
  81. 3
      src/Module/Oembed.php
  82. 5
      src/Module/OpenSearch.php
  83. 3
      src/Module/Outbox.php
  84. 3
      src/Module/Photo.php
  85. 3
      src/Module/Pinned.php
  86. 5
      src/Module/Profile.php
  87. 3
      src/Module/Profile/Contacts.php
  88. 7
      src/Module/Proxy.php
  89. 3
      src/Module/PublicRSAKey.php
  90. 3
      src/Module/RandomProfile.php
  91. 3
      src/Module/ReallySimpleDiscovery.php
  92. 7
      src/Module/Register.php
  93. 3
      src/Module/Search/Directory.php
  94. 5
      src/Module/Search/Index.php
  95. 3
      src/Module/Search/Saved.php
  96. 9
      src/Module/Security/Login.php
  97. 3
      src/Module/Security/Logout.php
  98. 7
      src/Module/Security/TwoFactor/Recovery.php
  99. 7
      src/Module/Security/TwoFactor/Verify.php
  100. 11
      src/Module/Settings/Delegation.php

2
bin/daemon.php

@ -37,7 +37,7 @@ $dice = (new Dice())->addRules(include __DIR__ . '/../static/dependencies.config
$dice = $dice->addRule(LoggerInterface::class,['constructParams' => ['daemon']]);
\Friendica\BaseObject::setDependencyInjection($dice);
$a = \Friendica\BaseObject::getApp();
$a = \Friendica\DI::app();
if ($a->getMode()->isInstall()) {
die("Friendica isn't properly installed yet.\n");

2
bin/worker.php

@ -36,7 +36,7 @@ $dice = (new Dice())->addRules(include __DIR__ . '/../static/dependencies.config
$dice = $dice->addRule(LoggerInterface::class,['constructParams' => ['worker']]);
BaseObject::setDependencyInjection($dice);
$a = BaseObject::getApp();
$a = Friendica\DI::app();
// Check the database structure and possibly fixes it
Update::check($a->getBasePath(), true, $a->getMode());

6
boot.php

@ -23,8 +23,8 @@ use Friendica\Core\Config;
use Friendica\Core\PConfig;
use Friendica\Core\Protocol;
use Friendica\Core\System;
use Friendica\Core\Session;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\Term;
use Friendica\Util\BasePath;
@ -241,12 +241,12 @@ if (!defined('CURLE_OPERATION_TIMEDOUT')) {
* Useful in functions which require it but don't get it passed to them
*
* @deprecated since version 2018.09
* @see BaseObject::getApp()
* @see DI::app()
* @return App
*/
function get_app()
{
return BaseObject::getApp();
return DI::app();
}
/**

6
include/api.php

@ -1370,7 +1370,7 @@ function api_get_item(array $condition)
*/
function api_users_show($type)
{
$a = BaseObject::getApp();
$a = Friendica\DI::app();
$user_info = api_get_user($a);
@ -2968,7 +2968,7 @@ function api_format_items_profiles($profile_row)
*/
function api_format_items($items, $user_info, $filter_user = false, $type = "json")
{
$a = BaseObject::getApp();
$a = Friendica\DI::app();
$ret = [];
@ -3002,7 +3002,7 @@ function api_format_items($items, $user_info, $filter_user = false, $type = "jso
*/
function api_format_item($item, $type = "json", $status_user = null, $author_user = null, $owner_user = null)
{
$a = BaseObject::getApp();
$a = Friendica\DI::app();
if (empty($status_user) || empty($author_user) || empty($owner_user)) {
list($status_user, $author_user, $owner_user) = api_item_get_user($a, $item);

2
include/items.php

@ -344,7 +344,7 @@ function drop_items(array $items)
function drop_item($id, $return = '')
{
$a = BaseObject::getApp();
$a = Friendica\DI::app();
// locate item to be deleted

2
index.php

@ -17,7 +17,7 @@ $dice = $dice->addRule(Friendica\App\Mode::class, ['call' => [['determineRunMode
\Friendica\BaseObject::setDependencyInjection($dice);
$a = \Friendica\BaseObject::getApp();
$a = \Friendica\DI::app();
$a->runFrontend(
$dice->create(\Friendica\App\Module::class),

13
src/BaseObject.php

@ -31,18 +31,7 @@ class BaseObject
public static function setDependencyInjection(Dice $dice)
{
self::$dice = $dice;
}
/**
* Get the app
*
* Same as get_app from boot.php
*
* @return App
*/
public static function getApp()
{
return self::getClass(App::class);
DI::init($dice);
}
/**

2
src/Console/PostUpdate.php

@ -57,7 +57,7 @@ HELP;
protected function doExecute()
{
$a = \Friendica\BaseObject::getApp();
$a = \Friendica\DI::app();
if ($this->getOption($this->helpOptions)) {
$this->out($this->getHelp());

9
src/Content/Text/BBCode.php

@ -19,6 +19,7 @@ use Friendica\Core\Logger;
use Friendica\Core\Protocol;
use Friendica\Core\Renderer;
use Friendica\Core\System;
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\Event;
use Friendica\Model\Photo;
@ -1093,7 +1094,7 @@ class BBCode extends BaseObject
$text = Cache::get($cache_key);
if (is_null($text)) {
$a = self::getApp();
$a = DI::app();
$stamp1 = microtime(true);
@ -1149,7 +1150,7 @@ class BBCode extends BaseObject
private static function cleanPictureLinksCallback($match)
{
$a = self::getApp();
$a = DI::app();
// When the picture link is the own photo path then we can avoid fetching the link
$own_photo_url = preg_quote(Strings::normaliseLink($a->getBaseURL()) . '/photos/');
@ -1253,7 +1254,7 @@ class BBCode extends BaseObject
*/
public static function convert($text, $try_oembed = true, $simple_html = 0, $for_plaintext = false)
{
$a = self::getApp();
$a = DI::app();
/*
* preg_match_callback function to replace potential Oembed tags with Oembed content
@ -2010,7 +2011,7 @@ class BBCode extends BaseObject
*/
public static function toMarkdown($text, $for_diaspora = true)
{
$a = self::getApp();
$a = DI::app();
$original_text = $text;

3
src/Content/Text/Markdown.php

@ -8,6 +8,7 @@ namespace Friendica\Content\Text;
use Friendica\BaseObject;
use Friendica\Core\System;
use Friendica\DI;
use Friendica\Model\Contact;
/**
@ -43,7 +44,7 @@ class Markdown extends BaseObject
$html = $MarkdownParser->transform($text);
self::getApp()->getProfiler()->saveTimestamp($stamp1, "parser", System::callstack());
DI::app()->getProfiler()->saveTimestamp($stamp1, "parser", System::callstack());
return $html;
}

5
src/Core/ACL.php

@ -9,6 +9,7 @@ namespace Friendica\Core;
use Friendica\App\Page;
use Friendica\BaseObject;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\Group;
@ -35,7 +36,7 @@ class ACL extends BaseObject
*/
public static function getSuggestContactSelectHTML($selname, $selclass, array $options = [], array $preselected = [])
{
$a = self::getApp();
$a = DI::app();
$networks = null;
@ -145,7 +146,7 @@ class ACL extends BaseObject
*/
public static function getMessageContactSelectHTML($selname, $selclass, array $preselected = [], $size = 4, $tabindex = null)
{
$a = self::getApp();
$a = DI::app();
$o = '';

9
src/Core/Addon.php

@ -7,6 +7,7 @@ namespace Friendica\Core;
use Friendica\BaseObject;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Util\Strings;
/**
@ -177,7 +178,7 @@ class Addon extends BaseObject
@include_once('addon/' . $addon . '/' . $addon . '.php');
if (function_exists($addon . '_install')) {
$func = $addon . '_install';
$func(self::getApp());
$func(DI::app());
$addon_admin = (function_exists($addon . "_addon_admin") ? 1 : 0);
@ -234,11 +235,11 @@ class Addon extends BaseObject
if (function_exists($addon . '_uninstall')) {
$func = $addon . '_uninstall';
$func(self::getApp());
$func(DI::app());
}
if (function_exists($addon . '_install')) {
$func = $addon . '_install';
$func(self::getApp());
$func(DI::app());
}
DBA::update('addon', ['timestamp' => $t], ['id' => $i['id']]);
}
@ -267,7 +268,7 @@ class Addon extends BaseObject
*/
public static function getInfo($addon)
{
$a = self::getApp();
$a = DI::app();
$addon = Strings::sanitizeFilePathItem($addon);

9
src/Core/Hook.php

@ -7,6 +7,7 @@ namespace Friendica\Core;
use Friendica\App;
use Friendica\BaseObject;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Util\Strings;
/**
@ -75,7 +76,7 @@ class Hook extends BaseObject
*/
public static function register($hook, $file, $function, $priority = 0)
{
$file = str_replace(self::getApp()->getBasePath() . DIRECTORY_SEPARATOR, '', $file);
$file = str_replace(DI::app()->getBasePath() . DIRECTORY_SEPARATOR, '', $file);
$condition = ['hook' => $hook, 'file' => $file, 'function' => $function];
if (DBA::exists('hook', $condition)) {
@ -98,7 +99,7 @@ class Hook extends BaseObject
*/
public static function unregister($hook, $file, $function)
{
$relative_file = str_replace(self::getApp()->getBasePath() . DIRECTORY_SEPARATOR, '', $file);
$relative_file = str_replace(DI::app()->getBasePath() . DIRECTORY_SEPARATOR, '', $file);
// This here is only needed for fixing a problem that existed on the develop branch
$condition = ['hook' => $hook, 'file' => $file, 'function' => $function];
@ -148,7 +149,7 @@ class Hook extends BaseObject
if ($hook[0] != $fork_hook[0]) {
continue;
}
self::callSingle(self::getApp(), 'hook_fork', $fork_hook, $hookdata);
self::callSingle(DI::app(), 'hook_fork', $fork_hook, $hookdata);
}
if (!$hookdata['execute']) {
@ -175,7 +176,7 @@ class Hook extends BaseObject
{
if (array_key_exists($name, self::$hooks)) {
foreach (self::$hooks[$name] as $hook) {
self::callSingle(self::getApp(), $name, $hook, $data);
self::callSingle(DI::app(), $name, $hook, $data);
}
}
}

5
src/Core/Renderer.php

@ -7,6 +7,7 @@ namespace Friendica\Core;
use Exception;
use Friendica\BaseObject;
use Friendica\DI;
use Friendica\Render\FriendicaSmarty;
use Friendica\Render\ITemplateEngine;
@ -61,7 +62,7 @@ class Renderer extends BaseObject
public static function replaceMacros($s, array $vars = [])
{
$stamp1 = microtime(true);
$a = self::getApp();
$a = DI::app();
// pass $baseurl to all templates if it isn't set
$vars = array_merge(['$baseurl' => $a->getBaseURL()], $vars);
@ -92,7 +93,7 @@ class Renderer extends BaseObject
public static function getMarkupTemplate($s, $root = '')
{
$stamp1 = microtime(true);
$a = self::getApp();
$a = DI::app();
$t = self::getTemplateEngine();
try {

5
src/Core/Search.php

@ -4,6 +4,7 @@ namespace Friendica\Core;
use Friendica\BaseObject;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\GContact;
use Friendica\Network\HTTPException;
@ -92,7 +93,7 @@ class Search extends BaseObject
*/
public static function getContactsFromGlobalDirectory($search, $type = self::TYPE_ALL, $page = 1)
{
$config = self::getApp()->getConfig();
$config = DI::app()->getConfig();
$server = $config->get('system', 'directory', self::DEFAULT_DIRECTORY);
$searchUrl = $server . '/search';
@ -158,7 +159,7 @@ class Search extends BaseObject
*/
public static function getContactsFromLocalDirectory($search, $type = self::TYPE_ALL, $start = 0, $itemPage = 80)
{
$config = self::getApp()->getConfig();
$config = DI::app()->getConfig();
$diaspora = $config->get('system', 'diaspora_enabled') ? Protocol::DIASPORA : Protocol::DFRN;
$ostatus = !$config->get('system', 'ostatus_disabled') ? Protocol::OSTATUS : Protocol::DFRN;

5
src/Core/System.php

@ -6,6 +6,7 @@ namespace Friendica\Core;
use Friendica\App\BaseURL;
use Friendica\BaseObject;
use Friendica\DI;
use Friendica\Network\HTTPException\InternalServerErrorException;
use Friendica\Util\XML;
@ -43,7 +44,7 @@ class System extends BaseObject
*/
public static function removedBaseUrl(string $orig_url)
{
return self::getApp()->removeBaseURL($orig_url);
return DI::app()->removeBaseURL($orig_url);
}
/**
@ -184,7 +185,7 @@ class System extends BaseObject
if (is_bool($prefix) && !$prefix) {
$prefix = '';
} elseif (empty($prefix)) {
$prefix = hash('crc32', self::getApp()->getHostName());
$prefix = hash('crc32', DI::app()->getHostName());
}
while (strlen($prefix) < ($size - 13)) {

5
src/Core/Theme.php

@ -7,6 +7,7 @@
namespace Friendica\Core;
use Friendica\BaseObject;
use Friendica\DI;
use Friendica\Model\Profile;
use Friendica\Util\Strings;
@ -194,7 +195,7 @@ class Theme
*/
public static function getPathForFile($file)
{
$a = BaseObject::getApp();
$a = DI::app();
$theme = $a->getCurrentTheme();
@ -232,7 +233,7 @@ class Theme
return 'view/theme/' . $theme . '/style.css';
}
$a = BaseObject::getApp();
$a = DI::app();
$query_params = [];

5
src/Core/Worker.php

@ -7,6 +7,7 @@ namespace Friendica\Core;
use Friendica\BaseObject;
use Friendica\Core;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Process;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Network;
@ -1232,11 +1233,11 @@ class Worker
*/
public static function defer()
{
if (empty(BaseObject::getApp()->queue)) {
if (empty(DI::app()->queue)) {
return false;
}
$queue = BaseObject::getApp()->queue;
$queue = DI::app()->queue;
$retrial = $queue['retrial'];
$id = $queue['id'];

33
src/DI.php

@ -0,0 +1,33 @@
<?php
namespace Friendica;
use Dice\Dice;
/**
* This class is capable of getting all dynamic created classes
*
* There has to be a "method" phpDoc for each new class, containing result class for a proper matching
*
* @method static App app()
*/
class DI
{
/** @var Dice */
private static $dice;
public static function init(Dice $dice)
{
self::$dice = $dice;
}
public static function __callStatic($name, $arguments)
{
switch ($name) {
case 'app':
return self::$dice->create(App::class, $arguments);
default:
return null;
}
}
}

2
src/LegacyModule.php

@ -67,7 +67,7 @@ class LegacyModule extends BaseModule
$function_name = static::$moduleName . '_' . $function_suffix;
if (\function_exists($function_name)) {
$a = self::getApp();
$a = DI::app();
return $function_name($a);
} else {
return parent::{$function_suffix}($parameters);

3
src/Model/Attach.php

@ -11,6 +11,7 @@ use Friendica\Core\StorageManager;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\Database\DBStructure;
use Friendica\DI;
use Friendica\Model\Storage\IStorage;
use Friendica\Object\Image;
use Friendica\Util\DateTimeFormat;
@ -31,7 +32,7 @@ class Attach extends BaseObject
*/
private static function getFields()
{
$allfields = DBStructure::definition(self::getApp()->getBasePath(), false);
$allfields = DBStructure::definition(DI::app()->getBasePath(), false);
$fields = array_keys($allfields['attach']['fields']);
array_splice($fields, array_search('data', $fields), 1);
return $fields;

3
src/Model/Contact.php

@ -16,6 +16,7 @@ use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\Core\Worker;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Network\Probe;
use Friendica\Object\Image;
use Friendica\Protocol\Activity;
@ -1733,7 +1734,7 @@ class Contact extends BaseObject
*/
public static function getPostsFromUrl($contact_url, $thread_mode = false, $update = 0)
{
$a = self::getApp();
$a = DI::app();
$cid = self::getIdForURL($contact_url);

9
src/Model/Item.php

@ -21,6 +21,7 @@ use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\Core\Worker;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Protocol\Activity;
use Friendica\Protocol\ActivityPub;
use Friendica\Protocol\Diaspora;
@ -2513,7 +2514,7 @@ class Item extends BaseObject
$guid = System::createUUID();
}
return self::getApp()->getBaseURL() . '/objects/' . $guid;
return DI::app()->getBaseURL() . '/objects/' . $guid;
}
/**
@ -3474,7 +3475,7 @@ class Item extends BaseObject
*/
private static function addRedirToImageTags(array &$item)
{
$app = self::getApp();
$app = DI::app();
$matches = [];
$cnt = preg_match_all('|\[img\](http[^\[]*?/photo/[a-fA-F0-9]+?(-[0-9]\.[\w]+?)?)\[\/img\]|', $item['body'], $matches, PREG_SET_ORDER);
@ -3509,7 +3510,7 @@ class Item extends BaseObject
*/
public static function prepareBody(array &$item, $attach = false, $is_preview = false)
{
$a = self::getApp();
$a = DI::app();
Hook::callAll('prepare_body_init', $item);
// In order to provide theme developers more possibilities, event items
@ -3647,7 +3648,7 @@ class Item extends BaseObject
*/
public static function getPlink($item)
{
$a = self::getApp();
$a = DI::app();
if ($a->user['nickname'] != "") {
$ret = [

3
src/Model/Nodeinfo.php

@ -5,6 +5,7 @@ namespace Friendica\Model;
use Friendica\BaseObject;
use Friendica\Core\Addon;
use Friendica\Database\DBA;
use Friendica\DI;
/**
* Model interaction for the nodeinfo
@ -18,7 +19,7 @@ class Nodeinfo extends BaseObject
*/
public static function update()
{
$app = self::getApp();
$app = DI::app();
$config = $app->getConfig();
$logger = $app->getLogger();

5
src/Model/Notify.php

@ -12,6 +12,7 @@ use Friendica\Core\L10n\L10n;
use Friendica\Core\Protocol;
use Friendica\Core\System;
use Friendica\Database\Database;
use Friendica\DI;
use Friendica\Protocol\Activity;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Proxy as ProxyUtils;
@ -515,7 +516,7 @@ final class Notify extends BaseObject
$ident = self::PERSONAL;
$notifies = [];
$myurl = str_replace('http://', '', self::getApp()->contact['nurl']);
$myurl = str_replace('http://', '', DI::app()->contact['nurl']);
$diasp_url = str_replace('/profile/', '/u/', $myurl);
$condition = ["NOT `wall` AND `uid` = ? AND (`item`.`author-id` = ? OR `item`.`tag` REGEXP ? OR `item`.`tag` REGEXP ?)",
@ -669,7 +670,7 @@ final class Notify extends BaseObject
// We have to distinguish between these two because they use different data.
// Contact suggestions
if ($intro['fid']) {
$return_addr = bin2hex(self::getApp()->user['nickname'] . '@' .
$return_addr = bin2hex(DI::app()->user['nickname'] . '@' .
$this->baseUrl->getHostName() .
(($this->baseUrl->getURLPath()) ? '/' . $this->baseUrl->getURLPath() : ''));

3
src/Model/Photo.php

@ -15,6 +15,7 @@ use Friendica\Core\StorageManager;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\Database\DBStructure;
use Friendica\DI;
use Friendica\Model\Storage\IStorage;
use Friendica\Object\Image;
use Friendica\Util\DateTimeFormat;
@ -202,7 +203,7 @@ class Photo extends BaseObject
*/
private static function getFields()
{
$allfields = DBStructure::definition(self::getApp()->getBasePath(), false);
$allfields = DBStructure::definition(DI::app()->getBasePath(), false);
$fields = array_keys($allfields["photo"]["fields"]);
array_splice($fields, array_search("data", $fields), 1);
return $fields;

5
src/Module/Admin/Addons/Details.php

@ -6,6 +6,7 @@ use Friendica\Content\Text\Markdown;
use Friendica\Core\Addon;
use Friendica\Core\L10n;
use Friendica\Core\Renderer;
use Friendica\DI;
use Friendica\Module\BaseAdminModule;
use Friendica\Util\Strings;
@ -15,7 +16,7 @@ class Details extends BaseAdminModule
{
parent::post($parameters);
$a = self::getApp();
$a = DI::app();
if ($a->argc > 2) {
// @TODO: Replace with parameter from router
@ -39,7 +40,7 @@ class Details extends BaseAdminModule
{
parent::content($parameters);
$a = self::getApp();
$a = DI::app();
$addons_admin = Addon::getAdminList();

3
src/Module/Admin/Addons/Index.php

@ -5,6 +5,7 @@ namespace Friendica\Module\Admin\Addons;
use Friendica\Core\Addon;
use Friendica\Core\L10n;
use Friendica\Core\Renderer;
use Friendica\DI;
use Friendica\Module\BaseAdminModule;
class Index extends BaseAdminModule
@ -13,7 +14,7 @@ class Index extends BaseAdminModule
{
parent::content($parameters);
$a = self::getApp();
$a = DI::app();
// reload active themes
if (!empty($_GET['action'])) {

5
src/Module/Admin/Blocklist/Contact.php

@ -6,6 +6,7 @@ use Friendica\Content\Pager;
use Friendica\Core\L10n;
use Friendica\Core\Renderer;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Module\BaseAdminModule;
use Friendica\Model;
@ -38,14 +39,14 @@ class Contact extends BaseAdminModule
notice(L10n::tt('%s contact unblocked', '%s contacts unblocked', count($contacts)));
}
self::getApp()->internalRedirect('admin/blocklist/contact');
DI::app()->internalRedirect('admin/blocklist/contact');
}
public static function content(array $parameters = [])
{
parent::content($parameters);
$a = self::getApp();
$a = DI::app();
$condition = ['uid' => 0, 'blocked' => true];

5
src/Module/Admin/Blocklist/Server.php

@ -5,6 +5,7 @@ namespace Friendica\Module\Admin\Blocklist;
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\Renderer;
use Friendica\DI;
use Friendica\Module\BaseAdminModule;
use Friendica\Util\Strings;
@ -47,14 +48,14 @@ class Server extends BaseAdminModule
info(L10n::t('Site blocklist updated.') . EOL);
}
self::getApp()->internalRedirect('admin/blocklist/server');
DI::app()->internalRedirect('admin/blocklist/server');
}
public static function content(array $parameters = [])
{
parent::content($parameters);
$a = self::getApp();
$a = DI::app();
$blocklist = Config::get('system', 'blocklist');
$blocklistform = [];

3
src/Module/Admin/DBSync.php

@ -8,6 +8,7 @@ use Friendica\Core\Renderer;
use Friendica\Core\Update;
use Friendica\Database\DBA;
use Friendica\Database\DBStructure;
use Friendica\DI;
use Friendica\Module\BaseAdminModule;
class DBSync extends BaseAdminModule
@ -16,7 +17,7 @@ class DBSync extends BaseAdminModule
{
parent::content($parameters);
$a = self::getApp();
$a = DI::app();
$o = '';

3
src/Module/Admin/Features.php

@ -6,6 +6,7 @@ use Friendica\Content\Feature;
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\Renderer;
use Friendica\DI;
use Friendica\Module\BaseAdminModule;
class Features extends BaseAdminModule
@ -39,7 +40,7 @@ class Features extends BaseAdminModule
}
}
self::getApp()->internalRedirect('admin/features');
DI::app()->internalRedirect('admin/features');
}
public static function content(array $parameters = [])

3
src/Module/Admin/Item/Delete.php

@ -4,6 +4,7 @@ namespace Friendica\Module\Admin\Item;
use Friendica\Core\L10n;
use Friendica\Core\Renderer;
use Friendica\DI;
use Friendica\Model\Item;
use Friendica\Module\BaseAdminModule;
use Friendica\Util\Strings;
@ -33,7 +34,7 @@ class Delete extends BaseAdminModule
}
info(L10n::t('Item marked for deletion.') . EOL);
self::getApp()->internalRedirect('admin/item/delete');
DI::app()->internalRedirect('admin/item/delete');
}
public static function content(array $parameters = [])

3
src/Module/Admin/Item/Source.php

@ -4,6 +4,7 @@ namespace Friendica\Module\Admin\Item;
use Friendica\Core\L10n;
use Friendica\Core\Renderer;
use Friendica\DI;
use Friendica\Model;
use Friendica\Module\BaseAdminModule;
@ -17,7 +18,7 @@ class Source extends BaseAdminModule
{
parent::content($parameters);
$a = self::getApp();
$a = DI::app();
$guid = null;
// @TODO: Replace with parameter from router

5
src/Module/Admin/Logs/Settings.php

@ -5,6 +5,7 @@ namespace Friendica\Module\Admin\Logs;
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\Renderer;
use Friendica\DI;
use Friendica\Module\BaseAdminModule;
use Friendica\Util\Strings;
use Psr\Log\LogLevel;
@ -34,14 +35,14 @@ class Settings extends BaseAdminModule
}
info(L10n::t("Log settings updated."));
self::getApp()->internalRedirect('admin/logs');
DI::app()->internalRedirect('admin/logs');
}
public static function content(array $parameters = [])
{
parent::content($parameters);
$a = self::getApp();
$a = DI::app();
$log_choices = [
LogLevel::ERROR => 'Error',

3
src/Module/Admin/Queue.php

@ -5,6 +5,7 @@ namespace Friendica\Module\Admin;
use Friendica\Core\L10n;
use Friendica\Core\Renderer;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Module\BaseAdminModule;
use Friendica\Util\Arrays;
use Friendica\Util\DateTimeFormat;
@ -23,7 +24,7 @@ class Queue extends BaseAdminModule
{
parent::content($parameters);
$a = self::getApp();
$a = DI::app();
// @TODO: Replace with parameter from router
$deferred = $a->argc > 2 && $a->argv[2] == 'deferred';

5
src/Module/Admin/Site.php

@ -10,6 +10,7 @@ use Friendica\Core\StorageManager;
use Friendica\Core\Theme;
use Friendica\Core\Worker;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Module\BaseAdminModule;
use Friendica\Module\Register;
use Friendica\Protocol\PortableContact;
@ -27,7 +28,7 @@ class Site extends BaseAdminModule
self::checkFormSecurityTokenRedirectOnError('/admin/site', 'admin_site');
$a = self::getApp();
$a = DI::app();
if (!empty($_POST['republish_directory'])) {
Worker::add(PRIORITY_LOW, 'Directory');
@ -416,7 +417,7 @@ class Site extends BaseAdminModule
{
parent::content($parameters);
$a = self::getApp();
$a = DI::app();
/* Installed langs */
$lang_choices = L10n::getAvailableLanguages();

5
src/Module/Admin/Summary.php

@ -10,6 +10,7 @@ use Friendica\Core\Renderer;
use Friendica\Core\Update;
use Friendica\Database\DBA;
use Friendica\Database\DBStructure;
use Friendica\DI;
use Friendica\Model\Register;
use Friendica\Module\BaseAdminModule;
use Friendica\Network\HTTPException\InternalServerErrorException;
@ -24,7 +25,7 @@ class Summary extends BaseAdminModule
{
parent::content($parameters);
$a = self::getApp();
$a = DI::app();
// are there MyISAM tables in the DB? If so, trigger a warning message
$warningtext = [];
@ -208,7 +209,7 @@ class Summary extends BaseAdminModule
private static function checkSelfHostMeta()
{
// Fetch the host-meta to check if this really is a vital server
return Network::curl(self::getApp()->getBaseURL() . '/.well-known/host-meta')->isSuccess();
return Network::curl(DI::app()->getBaseURL() . '/.well-known/host-meta')->isSuccess();
}
}

5
src/Module/Admin/Themes/Details.php

@ -6,6 +6,7 @@ use Friendica\Content\Text\Markdown;
use Friendica\Core\L10n;
use Friendica\Core\Renderer;
use Friendica\Core\Theme;
use Friendica\DI;
use Friendica\Module\BaseAdminModule;
use Friendica\Util\Strings;
@ -15,7 +16,7 @@ class Details extends BaseAdminModule
{
parent::post($parameters);
$a = self::getApp();
$a = DI::app();
if ($a->argc > 2) {
// @TODO: Replace with parameter from router
@ -43,7 +44,7 @@ class Details extends BaseAdminModule
{
parent::content($parameters);
$a = self::getApp();
$a = DI::app();
if ($a->argc > 2) {
// @TODO: Replace with parameter from router

7
src/Module/Admin/Themes/Embed.php

@ -4,6 +4,7 @@ namespace Friendica\Module\Admin\Themes;
use Friendica\Core\L10n;
use Friendica\Core\Renderer;
use Friendica\DI;
use Friendica\Module\BaseAdminModule;
use Friendica\Util\Strings;
@ -11,7 +12,7 @@ class Embed extends BaseAdminModule
{
public static function init(array $parameters = [])
{
$a = self::getApp();
$a = DI::app();
if ($a->argc > 2) {
// @TODO: Replace with parameter from router
@ -27,7 +28,7 @@ class Embed extends BaseAdminModule
{
parent::post($parameters);
$a = self::getApp();
$a = DI::app();
if ($a->argc > 2) {
// @TODO: Replace with parameter from router
@ -57,7 +58,7 @@ class Embed extends BaseAdminModule
{
parent::content($parameters);
$a = self::getApp();
$a = DI::app();
if ($a->argc > 2) {
// @TODO: Replace with parameter from router

3
src/Module/Admin/Themes/Index.php

@ -6,6 +6,7 @@ use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\Renderer;
use Friendica\Core\Theme;
use Friendica\DI;
use Friendica\Module\BaseAdminModule;
use Friendica\Util\Strings;
@ -15,7 +16,7 @@ class Index extends BaseAdminModule
{
parent::content($parameters);
$a = self::getApp();
$a = DI::app();
$allowed_themes = Theme::getAllowedList();

3
src/Module/Admin/Tos.php

@ -5,6 +5,7 @@ namespace Friendica\Module\Admin;
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\Renderer;
use Friendica\DI;
use Friendica\Module\BaseAdminModule;
class Tos extends BaseAdminModule
@ -29,7 +30,7 @@ class Tos extends BaseAdminModule
info(L10n::t('The Terms of Service settings have been updated.'));
self::getApp()->internalRedirect('admin/tos');
DI::app()->internalRedirect('admin/tos');
}
public static function content(array $parameters = [])

5
src/Module/Admin/Users.php

@ -7,6 +7,7 @@ use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\Renderer;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Register;
use Friendica\Model\User;
use Friendica\Module\BaseAdminModule;
@ -19,7 +20,7 @@ class Users extends BaseAdminModule
{
parent::post($parameters);
$a = self::getApp();
$a = DI::app();
$pending = $_POST['pending'] ?? [];
$users = $_POST['user'] ?? [];
@ -135,7 +136,7 @@ class Users extends BaseAdminModule
{
parent::content($parameters);
$a = self::getApp();
$a = DI::app();
if ($a->argc > 3) {
// @TODO: Replace with parameter from router

3
src/Module/AllFriends.php

@ -7,6 +7,7 @@ use Friendica\Content\ContactSelector;
use Friendica\Content\Pager;
use Friendica\Core\L10n;
use Friendica\Core\Renderer;
use Friendica\DI;
use Friendica\Model;
use Friendica\Network\HTTPException;
use Friendica\Util\Proxy as ProxyUtils;
@ -18,7 +19,7 @@ class AllFriends extends BaseModule
{
public static function content(array $parameters = [])
{
$app = self::getApp();
$app = DI::app();
if (!local_user()) {
throw new HTTPException\ForbiddenException();

3
src/Module/Apps.php

@ -7,6 +7,7 @@ use Friendica\Content\Nav;
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\Renderer;
use Friendica\DI;
/**
* Shows the App menu
@ -17,7 +18,7 @@ class Apps extends BaseModule
{
$privateaddons = Config::get('config', 'private_addons');
if ($privateaddons === "1" && !local_user()) {
self::getApp()->internalRedirect();
DI::app()->internalRedirect();
}
}

3
src/Module/Attach.php

@ -10,6 +10,7 @@ use Friendica\BaseModule;
use Friendica\Core\L10n;
use Friendica\Core\Logger;
use Friendica\Core\System;
use Friendica\DI;
use Friendica\Model\Attach as MAttach;
/**
@ -22,7 +23,7 @@ class Attach extends BaseModule
*/
public static function rawContent(array $parameters = [])
{
$a = self::getApp();
$a = DI::app();
if ($a->argc != 2) {
throw new \Friendica\Network\HTTPException\BadRequestException();
}

7
src/Module/Base/Api.php

@ -5,6 +5,7 @@ namespace Friendica\Module\Base;
use Friendica\App\Arguments;
use Friendica\BaseModule;
use Friendica\Core\L10n;
use Friendica\DI;
use Friendica\Network\HTTPException;
require_once __DIR__ . '/../../../include/api.php';
@ -41,7 +42,7 @@ class Api extends BaseModule
throw new HTTPException\UnauthorizedException(L10n::t('Permission denied.'));
}
$a = self::getApp();
$a = DI::app();
if (!empty($a->user['uid']) && $a->user['uid'] != api_user()) {
throw new HTTPException\ForbiddenException(L10n::t('Permission denied.'));
@ -67,7 +68,7 @@ class Api extends BaseModule
*/
protected static function login()
{
api_login(self::getApp());
api_login(DI::app());
self::$current_user_id = api_user();
@ -86,7 +87,7 @@ class Api extends BaseModule
*/
protected static function getUser($contact_id = null)
{
return api_get_user(self::getApp(), $contact_id);
return api_get_user(DI::app(), $contact_id);
}
protected static function format($root_element, $data)

3
src/Module/BaseAdminModule.php

@ -7,6 +7,7 @@ use Friendica\Core\Addon;
use Friendica\Core\L10n;
use Friendica\Core\Renderer;
use Friendica\Core\Session;
use Friendica\DI;
use Friendica\Network\HTTPException\ForbiddenException;
require_once 'boot.php';
@ -50,7 +51,7 @@ abstract class BaseAdminModule extends BaseModule
public static function content(array $parameters = [])
{
$a = self::getApp();
$a = DI::app();
if (!is_site_admin()) {
notice(L10n::t('Please login to continue.'));

5
src/Module/BaseSearchModule.php

@ -9,6 +9,7 @@ use Friendica\Content\Pager;
use Friendica\Core\L10n;
use Friendica\Core\Renderer;
use Friendica\Core\Search;
use Friendica\DI;
use Friendica\Model;
use Friendica\Network\HTTPException;
use Friendica\Object\Search\ContactResult;
@ -33,7 +34,7 @@ class BaseSearchModule extends BaseModule
*/
public static function performContactSearch($search, $prefix = '')
{
$a = self::getApp();
$a = DI::app();
$config = $a->getConfig();
$type = Search::TYPE_ALL;
@ -97,7 +98,7 @@ class BaseSearchModule extends BaseModule
return '';
}
$a = self::getApp();
$a = DI::app();
$id = 0;
$entries = [];

3
src/Module/BaseSettingsModule.php