Introduce new DI container

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

View file

@ -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;

View file

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

View file

@ -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 = [

View file

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

View file

@ -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() : ''));

View file

@ -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;