use Dice\Dice;
use Friendica\App\Mode;
-use Friendica\BaseObject;
use Friendica\Util\ExAuth;
use Psr\Log\LoggerInterface;
$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);
$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()) {
use Dice\Dice;
use Friendica\App;
-use Friendica\BaseObject;
use Friendica\Core\Config;
use Friendica\Core\Update;
use Friendica\Core\Worker;
$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
*/
use Friendica\App;
-use Friendica\BaseObject;
use Friendica\Core\Config;
use Friendica\Core\PConfig;
use Friendica\Core\Protocol;
*/
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;
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;
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;
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 = [];
$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");
*/
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;
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;
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)
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;
$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']);
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);
* @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;
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';
$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();
*/
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;
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';
*/
use Friendica\App;
-use Friendica\BaseObject;
use Friendica\Content\Nav;
use Friendica\Content\Widget\CalendarExport;
use Friendica\Core\ACL;
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;
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'] ?? '');
*/
use Friendica\App;
-use Friendica\BaseObject;
use Friendica\Content\Pager;
use Friendica\Content\Text\BBCode;
use Friendica\Content\Text\HTML;
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;
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;
} 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'] ?? '');
$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);
* @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)
{
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']);
*/
use Friendica\App;
-use Friendica\BaseObject;
use Friendica\Content\Feature;
use Friendica\Content\ForumManager;
use Friendica\Content\Nav;
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;
$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;
}
$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 {
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;
$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
*/
use Friendica\App;
-use Friendica\BaseObject;
use Friendica\Content\Feature;
use Friendica\Content\Nav;
use Friendica\Content\Pager;
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;
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;
$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']) : '';
$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));
$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)) &&
use Friendica\App;
use Friendica\BaseModule;
-use Friendica\BaseObject;
use Friendica\Content\Feature;
use Friendica\Content\Nav;
use Friendica\Core\ACL;
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;
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']) : '';
namespace Friendica\App;
use Friendica\App;
-use Friendica\BaseObject;
+use Friendica\BaseModule;
use Friendica\Core;
use Friendica\LegacyModule;
use Friendica\Module\Home;
private $module;
/**
- * @var BaseObject The module class
+ * @var BaseModule The module class
*/
private $module_class;
*
* @author Hypolite Petovan <hypolite@mrpetovan.com>
*/
-abstract class BaseModule extends BaseObject
+abstract class BaseModule
{
/**
* @brief Initialization method common to both content() and post()
+++ /dev/null
-<?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.');
- }
- }
-}
use DOMDocument;
use DOMXPath;
use Exception;
-use Friendica\BaseObject;
use Friendica\Content\OEmbed;
use Friendica\Content\Smilies;
use Friendica\Core\Cache;
use Friendica\Util\Strings;
use Friendica\Util\XML;
-class BBCode extends BaseObject
+class BBCode
{
/**
* @brief Fetches attachment data that were generated the old way
namespace Friendica\Content\Text;
-use Friendica\BaseObject;
use Friendica\Core\System;
use Friendica\DI;
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
namespace Friendica\Core;
use Friendica\App\Page;
-use Friendica\BaseObject;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact;
*
* @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
namespace Friendica\Core;
-use Friendica\BaseObject;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Util\Strings;
/**
* Some functions to handle addons
*/
-class Addon extends BaseObject
+class Addon
{
/**
* The addon sub-directory
*/
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;
*/
public static function getAllKeys($prefix = null)
{
- return self::getClass(ICache::class)->getAllKeys($prefix);
+ return DI::cache()->getAllKeys($prefix);
}
/**
*/
public static function get($key)
{
- return self::getClass(ICache::class)->get($key);
+ return DI::cache()->get($key);
}
/**
*/
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);
}
/**
*/
public static function delete($key)
{
- return self::getClass(ICache::class)->delete($key);
+ return DI::cache()->delete($key);
}
/**
*/
public static function clear($outdated = true)
{
- return self::getClass(ICache::class)->clear($outdated);
+ return DI::cache()->clear($outdated);
}
}
*/
namespace Friendica\Core;
-use Friendica\BaseObject;
-use Friendica\Core\Config\Configuration;
+use Friendica\DI;
/**
* @brief Arbitrary system configuration storage
* 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.
*/
public static function load($cat = "config")
{
- self::getClass(Configuration::class)->load($cat);
+ DI::config()->load($cat);
}
/**
*/
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);
}
/**
*/
public static function set($cat, $key, $value)
{
- return self::getClass(Configuration::class)->set($cat, $key, $value);
+ return DI::config()->set($cat, $key, $value);
}
/**
*/
public static function delete($cat, $key)
{
- return self::getClass(Configuration::class)->delete($cat, $key);
+ return DI::config()->delete($cat, $key);
}
}
$className = $this->subConsoles[$command];
- Friendica\BaseObject::setDependencyInjection($this->dice);
+ Friendica\DI::init($this->dice);
/** @var Console $subconsole */
$subconsole = $this->dice->create($className, [$subargs]);
namespace Friendica\Core;
use Friendica\App;
-use Friendica\BaseObject;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Util\Strings;
/**
* Some functions to handle hooks
*/
-class Hook extends BaseObject
+class Hook
{
/**
* Array of registered hooks
*/
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
*/
public static function getCurrentLang()
{
- return self::getClass(L10nClass::class)->getCurrentLang();
+ return DI::l10n()->getCurrentLang();
}
/**
*/
public static function withLang(string $lang)
{
- return self::getClass(L10nClass::class)->withLang($lang);
+ DI::l10n()->withLang($lang);
}
/**
*/
public static function t($s, ...$vars)
{
- return self::getClass(L10nClass::class)->t($s, ...$vars);
+ return DI::l10n()->t($s, ...$vars);
}
/**
*/
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);
}
/**
*/
public static function getDay($s)
{
- return self::getClass(L10nClass::class)->getDay($s);
+ return DI::l10n()->getDay($s);
}
/**
*/
public static function getDayShort($s)
{
- return self::getClass(L10nClass::class)->getDayShort($s);
+ return DI::l10n()->getDayShort($s);
}
/**
*/
public static function getPokeVerbs()
{
- return self::getClass(L10nClass::class)->getPokeVerbs();
+ return DI::l10n()->getPokeVerbs();
}
}
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
*/
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);
}
/**
* @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);
}
/**
*/
public static function releaseAll()
{
- self::getClass(ILock::class)->releaseAll();
+ DI::lock()->releaseAll();
}
}
*/
namespace Friendica\Core;
-use Friendica\BaseObject;
+use Friendica\DI;
use Friendica\Util\Logger\WorkerLogger;
use Psr\Log\LoggerInterface;
use Psr\Log\LogLevel;
/**
* @brief Logger functions
*/
-class Logger extends BaseObject
+class Logger
{
/**
* @see Logger::error()
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
*
public static function enableWorker(string $functionName)
{
self::$type = self::TYPE_WORKER;
- self::getClass(self::$type)->setFunctionName($functionName);
+ self::getWorker()->setFunctionName($functionName);
}
/**
*/
public static function emergency($message, $context = [])
{
- self::getClass(self::$type)->emergency($message, $context);
+ self::getWorker()->emergency($message, $context);
}
/**
*/
public static function alert($message, $context = [])
{
- self::getClass(self::$type)->alert($message, $context);
+ self::getWorker()->alert($message, $context);
}
/**
*/
public static function critical($message, $context = [])
{
- self::getClass(self::$type)->critical($message, $context);
+ self::getWorker()->critical($message, $context);
}
/**
*/
public static function error($message, $context = [])
{
- self::getClass(self::$type)->error($message, $context);
+ self::getWorker()->error($message, $context);
}
/**
*/
public static function warning($message, $context = [])
{
- self::getClass(self::$type)->warning($message, $context);
+ self::getWorker()->warning($message, $context);
}
/**
*/
public static function notice($message, $context = [])
{
- self::getClass(self::$type)->notice($message, $context);
+ self::getWorker()->notice($message, $context);
}
/**
*/
public static function info($message, $context = [])
{
- self::getClass(self::$type)->info($message, $context);
+ self::getWorker()->info($message, $context);
}
/**
*/
public static function debug($message, $context = [])
{
- self::getClass(self::$type)->debug($message, $context);
+ self::getWorker()->debug($message, $context);
}
/**
*/
public static function log($msg, $level = LogLevel::INFO)
{
- self::getClass(self::$type)->log($level, $msg);
+ self::getWorker()->log($level, $msg);
}
/**
*/
public static function devLog($msg, $level = LogLevel::DEBUG)
{
- self::getClass('$devLogger')->log($level, $msg);
+ DI::devLogger()->log($level, $msg);
}
}
*/
namespace Friendica\Core;
-use Friendica\BaseObject;
-use Friendica\Core\Config\PConfiguration;
+use Friendica\DI;
/**
* @brief Management of user configuration storage
* 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.
*/
public static function load(int $uid, string $cat)
{
- self::getClass(PConfiguration::class)->load($uid, $cat);
+ DI::pConfig()->load($uid, $cat);
}
/**
*/
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);
}
/**
*/
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);
}
/**
*/
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);
}
}
namespace Friendica\Core;
use Exception;
-use Friendica\BaseObject;
use Friendica\DI;
use Friendica\Render\FriendicaSmarty;
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')
namespace Friendica\Core;
-use Friendica\BaseObject;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact;
* - Search in the local directory
* - Search in the global directory
*/
-class Search extends BaseObject
+class Search
{
const DEFAULT_DIRECTORY = 'https://dir.friendica.social';
*/
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;
*
* @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();
}
/**
*/
public static function getRemoteContactID($uid)
{
- /** @var ISession $session */
- $session = self::getClass(ISession::class);
+ $session = DI::session();
if (empty($session->get('remote')[$uid])) {
return false;
*/
public static function getUserIDForVisitorContactID($cid)
{
- /** @var ISession $session */
- $session = self::getClass(ISession::class);
+ $session = DI::session();
if (empty($session->get('remote'))) {
return false;
*/
public static function setVisitorsContacts()
{
- /** @var ISession $session */
- $session = self::getClass(ISession::class);
+ $session = DI::session();
$session->set('remote', []);
*/
public static function isAuthenticated()
{
- /** @var ISession $session */
- $session = self::getClass(ISession::class);
+ $session = DI::session();
return $session->get('authenticated', false);
}
*/
namespace Friendica\Core;
-use Friendica\App\BaseURL;
-use Friendica\BaseObject;
use Friendica\DI;
use Friendica\Network\HTTPException\InternalServerErrorException;
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);
}
/**
namespace Friendica\Core;
-use Friendica\BaseObject;
use Friendica\DI;
use Friendica\Model\Profile;
use Friendica\Util\Strings;
*/
namespace Friendica\Core;
-use Friendica\BaseObject;
use Friendica\Core;
use Friendica\Database\DBA;
use Friendica\DI;
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
* 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
{
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;
}
namespace Friendica\Database;
-use Friendica\BaseObject;
+use Friendica\DI;
use mysqli;
use mysqli_result;
use mysqli_stmt;
*
* This class is for the low level database stuff that does driver specific things.
*/
-class DBA extends BaseObject
+class DBA
{
/**
* Lowest possible date value
public static function connect()
{
- return self::getClass(Database::class)->connect();
+ return DI::dba()->connect();
}
/**
*/
public static function disconnect()
{
- self::getClass(Database::class)->disconnect();
+ DI::dba()->disconnect();
}
/**
*/
public static function reconnect()
{
- return self::getClass(Database::class)->reconnect();
+ return DI::dba()->reconnect();
}
/**
*/
public static function getConnection()
{
- return self::getClass(Database::class)->getConnection();
+ return DI::dba()->getConnection();
}
/**
*/
public static function serverInfo()
{
- return self::getClass(Database::class)->serverInfo();
+ return DI::dba()->serverInfo();
}
/**
*/
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();
}
/**
*/
public static function anyValueFallback($sql)
{
- return self::getClass(Database::class)->anyValueFallback($sql);
+ return DI::dba()->anyValueFallback($sql);
}
/**
{
$params = self::getParam(func_get_args());
- return self::getClass(Database::class)->p($sql, $params);
+ return DI::dba()->p($sql, $params);
}
/**
$params = self::getParam(func_get_args());
- return self::getClass(Database::class)->e($sql, $params);
+ return DI::dba()->e($sql, $params);
}
/**
*/
public static function exists($table, $condition)
{
- return self::getClass(Database::class)->exists($table, $condition);
+ return DI::dba()->exists($table, $condition);
}
/**
{
$params = self::getParam(func_get_args());
- return self::getClass(Database::class)->fetchFirst($sql, $params);
+ return DI::dba()->fetchFirst($sql, $params);
}
/**
*/
public static function affectedRows()
{
- return self::getClass(Database::class)->affectedRows();
+ return DI::dba()->affectedRows();
}
/**
*/
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
*/
public static function numRows($stmt)
{
- return self::getClass(Database::class)->numRows($stmt);
+ return DI::dba()->numRows($stmt);
}
/**
*/
public static function fetch($stmt)
{
- return self::getClass(Database::class)->fetch($stmt);
+ return DI::dba()->fetch($stmt);
}
/**
*/
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);
}
/**
*/
public static function lastInsertId()
{
- return self::getClass(Database::class)->lastInsertId();
+ return DI::dba()->lastInsertId();
}
/**
*/
public static function lock($table)
{
- return self::getClass(Database::class)->lock($table);
+ return DI::dba()->lock($table);
}
/**
*/
public static function unlock()
{
- return self::getClass(Database::class)->unlock();
+ return DI::dba()->unlock();
}
/**
*/
public static function transaction()
{
- return self::getClass(Database::class)->transaction();
+ return DI::dba()->transaction();
}
/**
*/
public static function commit()
{
- return self::getClass(Database::class)->commit();
+ return DI::dba()->commit();
}
/**
*/
public static function rollback()
{
- return self::getClass(Database::class)->rollback();
+ return DI::dba()->rollback();
}
/**
*/
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);
}
/**
*/
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);
}
/**
*/
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);
}
/**
*/
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);
}
/**
*/
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);
}
/**
*/
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);
}
/**
*/
public static function toArray($stmt, $do_close = true)
{
- return self::getClass(Database::class)->toArray($stmt, $do_close);
+ return DI::dba()->toArray($stmt, $do_close);
}
/**
*/
public static function errorNo()
{
- return self::getClass(Database::class)->errorNo();
+ return DI::dba()->errorNo();
}
/**
*/
public static function errorMessage()
{
- return self::getClass(Database::class)->errorMessage();
+ return DI::dba()->errorMessage();
}
/**
*/
public static function close($stmt)
{
- return self::getClass(Database::class)->close($stmt);
+ return DI::dba()->close($stmt);
}
/**
*/
public static function processlist()
{
- return self::getClass(Database::class)->processlist();
+ return DI::dba()->processlist();
}
/**
*/
public static function isResult($array)
{
- return self::getClass(Database::class)->isResult($array);
+ return DI::dba()->isResult($array);
}
/**
*/
public static function escapeArray(&$arr, $add_quotation = false)
{
- return self::getClass(Database::class)->escapeArray($arr, $add_quotation);
+ DI::dba()->escapeArray($arr, $add_quotation);
}
}
namespace Friendica\Model;
-use Friendica\BaseObject;
use Friendica\Content\Text\HTML;
use Friendica\Core\Logger;
use Friendica\Core\Config;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Strings;
-class APContact extends BaseObject
+class APContact
{
/**
* Resolves the profile url from the address by using webfinger
*/
namespace Friendica\Model;
-use Friendica\BaseObject;
use Friendica\Core\StorageManager;
use Friendica\Core\System;
use Friendica\Database\DBA;
/**
* Class to handle attach dabatase table
*/
-class Attach extends BaseObject
+class Attach
{
/**
namespace Friendica\Model;
use Friendica\App\BaseURL;
-use Friendica\BaseObject;
use Friendica\Content\Pager;
use Friendica\Core\Config;
use Friendica\Core\Hook;
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;
/**
* @brief functions for interacting with a contact
*/
-class Contact extends BaseObject
+class Contact
{
/**
* @deprecated since version 2019.03
namespace Friendica\Model;
-use Friendica\BaseObject;
use Friendica\Content\Text\BBCode;
use Friendica\Core\Hook;
use Friendica\Core\L10n;
/**
* @brief functions for interacting with the event database table
*/
-class Event extends BaseObject
+class Event
{
public static function getHTML(array $event, $simple = false)
namespace Friendica\Model;
use Friendica\BaseModule;
-use Friendica\BaseObject;
use Friendica\Core\L10n;
use Friendica\Core\Logger;
use Friendica\Core\Protocol;
/**
* @brief functions for interacting with the group database table
*/
-class Group extends BaseObject
+class Group
{
const FOLLOWERS = '~';
const MUTUALS = '&';
namespace Friendica\Model;
-use Friendica\BaseObject;
use Friendica\Content\Text\BBCode;
use Friendica\Content\Text\HTML;
use Friendica\Core\Config;
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;
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;
$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']);
*/
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);
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
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
namespace Friendica\Model;
-use Friendica\BaseObject;
use Friendica\Core\Addon;
use Friendica\Database\DBA;
use Friendica\DI;
/**
* Model interaction for the nodeinfo
*/
-class Nodeinfo extends BaseObject
+class Nodeinfo
{
/**
* Updates the info about the current node
use Exception;
use Friendica\App;
-use Friendica\BaseObject;
use Friendica\Content\Text\BBCode;
use Friendica\Content\Text\HTML;
use Friendica\Core\Config\PConfiguration;
* @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;
*/
namespace Friendica\Model;
-use Friendica\BaseObject;
use Friendica\Database\DBA;
/**
* @brief functions for interacting with the permission set of an object (item, photo, event, ...)
*/
-class PermissionSet extends BaseObject
+class PermissionSet
{
/**
* Fetch the id of a given permission set. Generate a new one when needed
*/
namespace Friendica\Model;
-use Friendica\BaseObject;
use Friendica\Core\Cache;
use Friendica\Core\Config;
use Friendica\Core\L10n;
/**
* Class to handle photo dabatase table
*/
-class Photo extends BaseObject
+class Photo
{
/**
* @brief Select rows from the photo table and returns them as array
*/
namespace Friendica\Model;
-use Friendica\BaseObject;
use Friendica\Database\DBA;
use Friendica\Util\DateTimeFormat;
/**
* @brief functions for interacting with a process
*/
-class Process extends BaseObject
+class Process
{
/**
* Insert a new process row. If the pid parameter is omitted, we use the current pid
namespace Friendica\Model;
-use Friendica\BaseObject;
use Friendica\Database\DBA;
/**
* Model for DB specific logic for the search entity
*/
-class Search extends BaseObject
+class Search
{
/**
* Returns the list of user defined tags (e.g. #Friendica)
namespace Friendica\Model\TwoFactor;
-use Friendica\BaseObject;
use Friendica\Database\DBA;
use Friendica\Model\User;
use Friendica\Util\DateTimeFormat;
*
* @package Friendica\Model
*/
-class AppSpecificPassword extends BaseObject
+class AppSpecificPassword
{
public static function countForUser($uid)
{
namespace Friendica\Model\TwoFactor;
-use Friendica\BaseObject;
use Friendica\Database\DBA;
use Friendica\Util\DateTimeFormat;
use PragmaRX\Random\Random;
*
* @package Friendica\Model
*/
-class RecoveryCode extends BaseObject
+class RecoveryCode
{
/**
* Returns the number of code the provided users can still use to replace a TOTP code
if (Config::get('system', 'debugging')) {
$file = Config::get('system', 'logfile');
- /** @var FileSystem $fileSystem */
- $fileSystem = self::getClass(FileSystem::class);
+ $fileSystem = DI::fs();
try {
$stream = $fileSystem->createStream($file);
namespace Friendica\Module\Api\Mastodon;
use Friendica\Api\Mastodon;
-use Friendica\App\BaseURL;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\Model\APContact;
+use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\Introduction;
use Friendica\Module\Base\Api;
$base_query['limit'] = $limit;
}
- /** @var BaseURL $BaseURL */
- $BaseURL = self::getClass(BaseURL::class);
+ $BaseURL = DI::baseUrl();
$links = [];
if ($count > $limit) {
public static function init(array $parameters = [])
{
- $Arguments = self::getClass(Arguments::class);
+ $arguments = DI::args();
- if (substr($Arguments->getQueryString(), -4) === '.xml') {
+ if (substr($arguments->getQueryString(), -4) === '.xml') {
self::$format = 'xml';
}
- if (substr($Arguments->getQueryString(), -4) === '.rss') {
+ if (substr($arguments->getQueryString(), -4) === '.rss') {
self::$format = 'rss';
}
- if (substr($Arguments->getQueryString(), -4) === '.atom') {
+ if (substr($arguments->getQueryString(), -4) === '.atom') {
self::$format = 'atom';
}
}
$header = L10n::t('Forum Search - %s', $search);
}
- /** @var Arguments $args */
- $args = self::getClass(Arguments::class);
+ $args = DI::args();
$pager = new Pager($args->getQueryString());
if ($localSearch && empty($results)) {
namespace Friendica\Module;
use Friendica\BaseModule;
-use Friendica\App\Authentication;
use Friendica\Core\Hook;
use Friendica\Core\L10n;
use Friendica\Core\Renderer;
Session::clear();
- /** @var Authentication $authentication */
- $authentication = self::getClass(Authentication::class);
- $authentication->setForUser(DI::app(), $user, true, true);
+ DI::auth()->setForUser(DI::app(), $user, true, true);
if ($limited_id) {
Session::set('submanage', $original_id);
use Friendica\BaseModule;
use Friendica\Core\Config\Configuration;
use Friendica\Core\L10n\L10n;
+use Friendica\DI;
use Friendica\Model\User;
use Friendica\Network\HTTPException;
use Friendica\Protocol\Diaspora;
public static function init(array $parameters = [])
{
- /** @var LoggerInterface $logger */
- self::$logger = self::getClass(LoggerInterface::class);
+ self::$logger = DI::logger();
}
public static function post(array $parameters = [])
{
- /** @var Configuration $config */
- $config = self::getClass(Configuration::class);
-
- $enabled = $config->get('system', 'diaspora_enabled', false);
+ $enabled = DI::config()->get('system', 'diaspora_enabled', false);
if (!$enabled) {
self::$logger->info('Diaspora disabled.');
- $l10n = self::getClass(L10n::class);
- throw new HTTPException\ForbiddenException($l10n->t('Access denied.'));
+ throw new HTTPException\ForbiddenException(DI::l10n()->t('Access denied.'));
}
- /** @var App\Arguments $args */
- $args = self::getClass(App\Arguments::class);
+ $args = DI::args();
$type = $args->get(1);
$user = User::getById(local_user(), ['allow_cid', 'allow_gid', 'deny_cid', 'deny_gid', 'hidewall', 'default-location']);
- /** @var ACLFormatter $aclFormatter */
- $aclFormatter = self::getClass(ACLFormatter::class);
+ $aclFormatter = DI::aclFormatter();
$contact_allow_list = $aclFormatter->expand($user['allow_cid']);
$group_allow_list = $aclFormatter->expand($user['allow_gid']);
{
public static function rawContent(array $parameters = [])
{
- /** @var L10n $l10n */
- $l10n = self::getClass(L10n::class);
+ $l10n = DI::l10n();
if (!Session::isAuthenticated()) {
throw new HttpException\ForbiddenException($l10n->t('Access denied.'));
}
- /** @var App\Arguments $args */
- $args = self::getClass(App\Arguments::class);
- /** @var Database $dba */
- $dba = self::getClass(Database::class);
+ $args = DI::args();
+ $dba = DI::dba();
$message_id = intval($args->get(2));
namespace Friendica\Module\Notifications;
use Friendica\BaseModule;
-use Friendica\BaseObject;
use Friendica\Core\L10n;
use Friendica\Core\System;
use Friendica\DI;
-use Friendica\Model\Notify as ModelNotify;
use Friendica\Network\HTTPException;
/**
// @TODO: Replace with parameter from router
if ($a->argc > 2 && $a->argv[1] === 'mark' && $a->argv[2] === 'all') {
- /** @var ModelNotify $notificationsManager */
- $notificationsManager = self::getClass(ModelNotify::class);
- $success = $notificationsManager->setAllSeen();
+ $success = DI::notify()->setAllSeen();
header('Content-type: application/json; charset=utf-8');
echo json_encode([
// @TODO: Replace with parameter from router
if ($a->argc > 2 && $a->argv[1] === 'view' && intval($a->argv[2])) {
- /** @var ModelNotify $notificationsManager */
- $notificationsManager = BaseObject::getClass(ModelNotify::class);
+ $notificationsManager = DI::notify();
// @TODO: Replace with parameter from router
$note = $notificationsManager->getByID($a->argv[2]);
if (!empty($note)) {
$category = $datequery = $datequery2 = '';
- /** @var DateTimeFormat $dtFormat */
- $dtFormat = self::getClass(DateTimeFormat::class);
-
if ($a->argc > 2) {
for ($x = 2; $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 {
$user = $result['user'];
- $base_url = self::getClass(BaseURL::class)->get();
+ $base_url = DI::baseUrl()->get();
if ($netpublish && intval(Config::get('config', 'register_policy')) !== self::APPROVE) {
$url = $base_url . '/profile/' . $user['nickname'];
// OR your own posts if you are a logged in member
// No items will be shown if the member has a blocked profile wall.
- /** @var Arguments $args */
- $args = self::getClass(Arguments::class);
- $pager = new Pager($args->getQueryString());
+ $pager = new Pager(DI::args()->getQueryString());
if ($tag) {
Logger::info('Start tag search.', ['q' => $search]);
namespace Friendica\Module\Search;
-use Friendica\App\Arguments;
use Friendica\BaseModule;
use Friendica\Core\L10n;
use Friendica\Database\DBA;
{
public static function init(array $parameters = [])
{
- /** @var Arguments $args */
- $args = self::getClass(Arguments::class);
-
- $action = $args->get(2, 'none');
+ $action = DI::args()->get(2, 'none');
$search = Strings::escapeTags(trim(rawurldecode($_GET['term'] ?? '')));
$return_url = $_GET['return_url'] ?? 'search?q=' . urlencode($search);
namespace Friendica\Module\Security;
use Friendica\BaseModule;
-use Friendica\App\Authentication;
use Friendica\Core\Config;
use Friendica\Core\Hook;
use Friendica\Core\L10n;
) {
$openid_url = trim(($_POST['openid_url'] ?? '') ?: $_POST['username']);
- /** @var Authentication $authentication */
- $authentication = self::getClass(Authentication::class);
- $authentication->withOpenId($openid_url, !empty($_POST['remember']));
+ DI::auth()->withOpenId($openid_url, !empty($_POST['remember']));
}
if (!empty($_POST['auth-params']) && $_POST['auth-params'] === 'login') {
- /** @var Authentication $authentication */
- $authentication = self::getClass(Authentication::class);
- $authentication->withPassword(
+ DI::auth()->withPassword(
DI::app(),
trim($_POST['username']),
trim($_POST['password']),
Session::set('2fa', true);
notice(L10n::t('Remaining recovery codes: %d', RecoveryCode::countValidForUser(local_user())));
- // Resume normal login workflow
- /** @var Authentication $authentication */
- $authentication = self::getClass(Authentication::class);
- $authentication->setForUser($a, $a->user, true, true);
+ DI::auth()->setForUser($a, $a->user, true, true);
} else {
notice(L10n::t('Invalid code, please retry.'));
}
Session::set('2fa', $code);
// Resume normal login workflow
- /** @var Authentication $authentication */
- $authentication = self::getClass(Authentication::class);
- $authentication->setForUser($a, $a->user, true, true);
+ DI::auth()->setForUser($a, $a->user, true, true);
} else {
self::$errors[] = L10n::t('Invalid code, please retry.');
}
throw new HTTPException\ForbiddenException(L10n::t('Permission denied.'));
}
- /** @var Arguments $args */
- $args = self::getClass(Arguments::class);
+ $args = DI::args();
// @TODO Replace with router-provided arguments
$action = $args->get(2);
**/
public static function rawContent(array $parameters = [])
{
- $args = self::getClass(Arguments::class);
+ $args = DI::args();
if ($args->getArgc() == 3) {
// @TODO Replace with router-provided arguments
$action = $args->get(2);
*/
namespace Friendica\Network;
-use Friendica\BaseObject;
-use Friendica\App\Authentication;
use Friendica\Core\Logger;
-use Friendica\Core\Session;
use Friendica\Database\DBA;
use Friendica\DI;
use OAuthServer;
die('This api requires login');
}
- /** @var Authentication $authentication */
- $authentication = BaseObject::getClass(Authentication::class);
- $authentication->setForUser($a, $record, true);
+ DI::auth()->setForUser($a, $record, true);
}
}
*/
namespace Friendica\Object;
-use Friendica\BaseObject;
use Friendica\Content\ContactSelector;
use Friendica\Content\Feature;
-use Friendica\Content\Item as ContentItem;
use Friendica\Core\Addon;
use Friendica\Core\Config;
use Friendica\Core\Hook;
/**
* An item
*/
-class Post extends BaseObject
+class Post
{
private $data = [];
private $template = null;
$body = Item::prepareBody($item, true);
- /** @var ContentItem $contItem */
- $contItem = self::getClass(ContentItem::class);
-
- list($categories, $folders) = $contItem->determineCategoriesTerms($item);
+ list($categories, $folders) = DI::contentItem()->determineCategoriesTerms($item);
$body_e = $body;
$text_e = strip_tags($body);
return false;
}
- /** @var Activity $activity */
- $activity = self::getClass(Activity::class);
+ $activity = DI::activity();
/*
* Only add what will be displayed
*/
namespace Friendica\Object;
-use Friendica\BaseObject;
use Friendica\Core\Logger;
use Friendica\Core\Protocol;
use Friendica\DI;
*
* We should think about making this a SPL Iterator
*/
-class Thread extends BaseObject
+class Thread
{
private $parents = [];
private $mode = null;
*/
namespace Friendica\Protocol\ActivityPub;
-use Friendica\BaseObject;
use Friendica\Content\Feature;
use Friendica\Content\Text\BBCode;
use Friendica\Content\Text\Plaintext;
use DOMDocument;
use DOMXPath;
use Friendica\App\BaseURL;
-use Friendica\BaseObject;
use Friendica\Content\OEmbed;
use Friendica\Content\Text\BBCode;
use Friendica\Content\Text\HTML;
use Friendica\Core\Protocol;
use Friendica\Core\System;
use Friendica\Database\DBA;
+use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\Conversation;
use Friendica\Model\Event;
use Friendica\Model\Profile;
use Friendica\Model\User;
use Friendica\Network\Probe;
-use Friendica\Object\Image;
-use Friendica\Protocol\ActivityNamespace;
use Friendica\Util\Crypto;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Images;
// The functions below are partly used by ostatus.php as well - where we have this variable
$contact = Contact::selectFirst([], ['id' => $importer['id']]);
- /** @var Activity $activity */
- $activity = BaseObject::getClass(Activity::class);
+ $activity = DI::activity();
// Big question: Do we need these functions? They were part of the "consume_feed" function.
// This function once was responsible for DFRN and OStatus.
namespace Friendica\Util;
-use Friendica\BaseObject;
use Friendica\Core\Cache;
use Friendica\Core\Logger;
use Friendica\Core\System;
namespace Friendica\Util;
-use Friendica\BaseObject;
use Friendica\Core\Config;
use Friendica\Core\System;
use Friendica\DI;
namespace Friendica\Util;
-use Friendica\BaseObject;
use Friendica\Database\DBA;
use Friendica\Model\Contact;
use Friendica\Model\Group;
/**
* Secures that User is allow to do requests
*/
-class Security extends BaseObject
+class Security
{
public static function canWriteToUserWall($owner)
{
*/
namespace Friendica\Worker;
-use Friendica\BaseObject;
use Friendica\Core\Logger;
use Friendica\Core\Worker;
use Friendica\Model\ItemDeliveryData;
use Friendica\Protocol\ActivityPub;
use Friendica\Util\HTTPSignature;
-class APDelivery extends BaseObject
+class APDelivery
{
/**
* @brief Delivers ActivityPub messages
*/
namespace Friendica\Worker;
-use Friendica\BaseObject;
use Friendica\Core\Addon;
use Friendica\Core\Config;
use Friendica\Core\Hook;
namespace Friendica\Worker;
use Friendica\App;
-use Friendica\BaseObject;
use Friendica\Core\Cache;
use Friendica\Core\Config;
use Friendica\Core\Logger;
*/
namespace Friendica\Worker;
-use Friendica\BaseObject;
use Friendica\Core\Config;
use Friendica\Core\Update;
use Friendica\DI;
-class DBUpdate extends BaseObject
+class DBUpdate
{
public static function execute()
{
*/
namespace Friendica\Worker;
-use Friendica\BaseObject;
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\Logger;
use Friendica\Util\Network;
use Friendica\Core\Worker;
-class Delivery extends BaseObject
+class Delivery
{
const MAIL = 'mail';
const SUGGESTION = 'suggest';
namespace Friendica\Worker;
-use Friendica\BaseObject;
use Friendica\Core\Config;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
*/
namespace Friendica\Worker;
-use Friendica\BaseObject;
use Friendica\Core\Config;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
$public_message = false; // private recipients, not public
}
- /** @var ACLFormatter $aclFormatter */
- $aclFormatter = BaseObject::getClass(ACLFormatter::class);
+ $aclFormatter = DI::aclFormatter();
$allow_people = $aclFormatter->expand($parent['allow_cid']);
$allow_groups = Group::expand($uid, $aclFormatter->expand($parent['allow_gid']),true);
*/
namespace Friendica\Worker;
-use Friendica\BaseObject;
-use Friendica\Content\Text\BBCode;
use Friendica\Core\Config;
use Friendica\Core\Logger;
use Friendica\Core\PConfig;
namespace Friendica\Worker;
-use Friendica\BaseObject;
use Friendica\Core\Logger;
use Friendica\Core\Worker;
use Friendica\DI;
use Dice\Dice;
use Friendica\App;
-use Friendica\BaseObject;
use Friendica\Core\Config;
+use Friendica\DI;
use Friendica\Render\FriendicaSmartyEngine;
use Friendica\Util\Profiler;
use Mockery\MockInterface;
return $this->configMock->get('system', 'url');
});
- BaseObject::setDependencyInjection($this->dice);
+ DI::init($this->dice);
if ($raw) {
return;
use Dice\Dice;
use Friendica\App;
-use Friendica\BaseObject;
use Friendica\Core\Config\Configuration;
use Friendica\Core\Config\PConfiguration;
use Friendica\Core\Protocol;
->addRules(include __DIR__ . '/../../static/dependencies.config.php')
->addRule(Database::class, ['instanceOf' => StaticDatabase::class, 'shared' => true])
->addRule(ISession::class, ['instanceOf' => Session\Memory::class, 'shared' => true, 'call' => null]);
- BaseObject::setDependencyInjection($this->dice);
+ DI::init($this->dice);
/** @var Database $dba */
$dba = $this->dice->create(Database::class);
// User ID that we know is not in the database
$this->wrongUserId = 666;
- /** @var ISession $session */
- $session = BaseObject::getClass(ISession::class);
+ $session = DI::session();
$session->start();
// Most API require login so we force the session
use Dice\Dice;
use Friendica\App;
-use Friendica\BaseObject;
use Friendica\Console\AutomaticInstallation;
use Friendica\Core\Config\Cache\ConfigCache;
use Friendica\Core\Installer;
use Friendica\Core\L10n\L10n;
use Friendica\Core\Logger;
use Friendica\Database\Database;
+use Friendica\DI;
use Friendica\Test\Util\DBAMockTrait;
use Friendica\Test\Util\DBStructureMockTrait;
use Friendica\Test\Util\RendererMockTrait;
->with(L10n::class)
->andReturn($l10nMock);
- BaseObject::setDependencyInjection($this->dice);
+ DI::init($this->dice);
$this->configCache = new ConfigCache();
$this->configCache->set('system', 'basepath', $this->root->url());
namespace Friendica\Core;
use Dice\Dice;
-use Friendica\BaseObject;
use Friendica\Core\Config\Cache\ConfigCache;
+use Friendica\DI;
use Friendica\Network\CurlResult;
-use Friendica\Object\Image;
use Friendica\Test\MockedTest;
use Friendica\Test\Util\VFSTrait;
use Friendica\Util\Network;
->with(\Friendica\Core\L10n\L10n::class)
->andReturn($this->l10nMock);
- BaseObject::setDependencyInjection($dice);
+ DI::init($dice);
}
private function mockL10nT(string $text, $times = null)
use Dice\Dice;
use Friendica\App;
-use Friendica\BaseObject;
use Friendica\Core\Config\Configuration;
use Friendica\Core\Lock\SemaphoreLock;
+use Friendica\DI;
class SemaphoreLockTest extends LockTest
{
$dice->shouldReceive('create')->with(Configuration::class)->andReturn($configMock);
// @todo Because "get_temppath()" is using static methods, we have to initialize the BaseObject
- BaseObject::setDependencyInjection($dice);
+ DI::init($dice);
parent::setUp();
}
namespace Friendica\Test\src\Database;
use Dice\Dice;
-use Friendica\BaseObject;
use Friendica\Core\Config;
use Friendica\Database\Database;
use Friendica\Database\DBA;
+use Friendica\DI;
use Friendica\Test\DatabaseTest;
use Friendica\Test\Util\Database\StaticDatabase;
$dice = (new Dice())
->addRules(include __DIR__ . '/../../../static/dependencies.config.php')
->addRule(Database::class, ['instanceOf' => StaticDatabase::class, 'shared' => true]);
- BaseObject::setDependencyInjection($dice);
+ DI::init($dice);
// Default config
Config::set('config', 'hostname', 'localhost');
namespace Friendica\Test\src\Database;
use Dice\Dice;
-use Friendica\BaseObject;
use Friendica\Database\Database;
use Friendica\Database\DBStructure;
+use Friendica\DI;
use Friendica\Test\DatabaseTest;
use Friendica\Test\Util\Database\StaticDatabase;
$dice = (new Dice())
->addRules(include __DIR__ . '/../../../static/dependencies.config.php')
->addRule(Database::class, ['instanceOf' => StaticDatabase::class, 'shared' => true]);
- BaseObject::setDependencyInjection($dice);
+ DI::init($dice);
}
/**
namespace Friendica\Test\src\Network;
use Dice\Dice;
-use Friendica\BaseObject;
+use Friendica\DI;
use Friendica\Network\CurlResult;
use Mockery\MockInterface;
use PHPUnit\Framework\TestCase;
->with(LoggerInterface::class)
->andReturn($logger);
- BaseObject::setDependencyInjection($dice);
+ DI::init($dice);
}
/**