Browse Source

Refactor dynamic App::getConfig() to static DI::config()

pull/8019/head
nupplaPhil 1 year ago
parent
commit
fceb4f3823
No known key found for this signature in database GPG Key ID: D8365C3D36B77D90
21 changed files with 38 additions and 66 deletions
  1. +0
    -10
      src/App.php
  2. +2
    -3
      src/Core/Search.php
  3. +1
    -1
      src/Core/Worker.php
  4. +1
    -1
      src/Model/Nodeinfo.php
  5. +1
    -1
      src/Module/Admin/Summary.php
  6. +1
    -1
      src/Module/BaseSearchModule.php
  7. +1
    -1
      src/Module/Bookmarklet.php
  8. +1
    -1
      src/Module/Directory.php
  9. +2
    -2
      src/Module/Friendica.php
  10. +1
    -1
      src/Module/Help.php
  11. +1
    -1
      src/Module/Home.php
  12. +2
    -2
      src/Module/Invite.php
  13. +1
    -3
      src/Module/Maintenance.php
  14. +1
    -2
      src/Module/Manifest.php
  15. +13
    -25
      src/Module/NodeInfo.php
  16. +1
    -1
      src/Module/Register.php
  17. +1
    -1
      src/Module/Security/Login.php
  18. +4
    -6
      src/Module/Statistics.php
  19. +1
    -1
      src/Module/Welcome.php
  20. +1
    -1
      src/Module/WellKnown/HostMeta.php
  21. +1
    -1
      src/Module/WellKnown/XSocialRelay.php

+ 0
- 10
src/App.php View File

@ -144,16 +144,6 @@ class App
return $this->config->getCache();
}
/**
* Returns the current config of this node
*
* @return Configuration
*/
public function getConfig()
{
return $this->config;
}
/**
* The basepath of this app
*


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

@ -92,8 +92,7 @@ class Search
*/
public static function getContactsFromGlobalDirectory($search, $type = self::TYPE_ALL, $page = 1)
{
$config = DI::app()->getConfig();
$server = $config->get('system', 'directory', self::DEFAULT_DIRECTORY);
$server = DI::config()->get('system', 'directory', self::DEFAULT_DIRECTORY);
$searchUrl = $server . '/search';
@ -158,7 +157,7 @@ class Search
*/
public static function getContactsFromLocalDirectory($search, $type = self::TYPE_ALL, $start = 0, $itemPage = 80)
{
$config = DI::app()->getConfig();
$config = DI::config();
$diaspora = $config->get('system', 'diaspora_enabled') ? Protocol::DIASPORA : Protocol::DFRN;
$ostatus = !$config->get('system', 'ostatus_disabled') ? Protocol::OSTATUS : Protocol::DFRN;


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

@ -1086,7 +1086,7 @@ class Worker
$args = ['no_cron' => !$do_cron];
$a = get_app();
$process = new Core\Process($a->getLogger(), $a->getMode(), $a->getConfig(), $a->getBasePath());
$process = new Core\Process($a->getLogger(), $a->getMode(), DI::config(), $a->getBasePath());
$process->run($command, $args);
// after spawning we have to remove the flag.


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

@ -19,7 +19,7 @@ class Nodeinfo
public static function update()
{
$app = DI::app();
$config = $app->getConfig();
$config = DI::config();
$logger = $app->getLogger();
// If the addon 'statistics_json' is enabled then disable it and activate nodeinfo.


+ 1
- 1
src/Module/Admin/Summary.php View File

@ -115,7 +115,7 @@ class Summary extends BaseAdminModule
$configCache = new Config\Cache\ConfigCache();
$configLoader->setupCache($configCache);
$confBasepath = $configCache->get('system', 'basepath');
$currBasepath = $a->getConfig()->get('system', 'basepath');
$currBasepath = DI::config()->get('system', 'basepath');
if ($confBasepath !== $currBasepath || !is_dir($currBasepath)) {
if (is_dir($confBasepath) && Config::set('system', 'basepath', $confBasepath)) {
$a->getLogger()->info('Friendica\'s system.basepath was updated successfully.', [


+ 1
- 1
src/Module/BaseSearchModule.php View File

@ -35,7 +35,7 @@ class BaseSearchModule extends BaseModule
public static function performContactSearch($search, $prefix = '')
{
$a = DI::app();
$config = $a->getConfig();
$config = DI::config();
$type = Search::TYPE_ALL;


+ 1
- 1
src/Module/Bookmarklet.php View File

@ -21,7 +21,7 @@ class Bookmarklet extends BaseModule
$_GET['mode'] = 'minimal';
$app = DI::app();
$config = $app->getConfig();
$config = DI::config();
if (!local_user()) {
$output = '<h2>' . L10n::t('Login') . '</h2>';


+ 1
- 1
src/Module/Directory.php View File

@ -25,7 +25,7 @@ class Directory extends BaseModule
public static function content(array $parameters = [])
{
$app = DI::app();
$config = $app->getConfig();
$config = DI::config();
if (($config->get('system', 'block_public') && !Session::isAuthenticated()) ||
($config->get('system', 'block_local_dir') && !Session::isAuthenticated())) {


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

@ -19,7 +19,7 @@ class Friendica extends BaseModule
public static function content(array $parameters = [])
{
$app = DI::app();
$config = $app->getConfig();
$config = DI::config();
$visibleAddonList = Addon::getVisibleList();
if (!empty($visibleAddonList)) {
@ -98,7 +98,7 @@ class Friendica extends BaseModule
return;
}
$config = $app->getConfig();
$config = DI::config();
$register_policies = [
Register::CLOSED => 'REGISTER_CLOSED',


+ 1
- 1
src/Module/Help.php View File

@ -23,7 +23,7 @@ class Help extends BaseModule
$filename = '';
$a = DI::app();
$config = $a->getConfig();
$config = DI::config();
$lang = $config->get('system', 'language');
// @TODO: Replace with parameter from router


+ 1
- 1
src/Module/Home.php View File

@ -17,7 +17,7 @@ class Home extends BaseModule
public static function content(array $parameters = [])
{
$app = DI::app();
$config = $app->getConfig();
$config = DI::config();
// currently no returned data is used
$ret = [];


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

@ -26,7 +26,7 @@ class Invite extends BaseModule
self::checkFormSecurityTokenRedirectOnError('/', 'send_invite');
$app = DI::app();
$config = $app->getConfig();
$config = DI::config();
$max_invites = intval($config->get('system', 'max_invites'));
if (!$max_invites) {
@ -112,7 +112,7 @@ class Invite extends BaseModule
}
$app = DI::app();
$config = $app->getConfig();
$config = DI::config();
$inviteOnly = false;


+ 1
- 3
src/Module/Maintenance.php View File

@ -17,9 +17,7 @@ class Maintenance extends BaseModule
{
public static function content(array $parameters = [])
{
$config = DI::app()->getConfig();
$reason = $config->get('system', 'maintenance_reason');
$reason = DI::config()->get('system', 'maintenance_reason');
if ((substr(Strings::normaliseLink($reason), 0, 7) === 'http://') ||
(substr(Strings::normaliseLink($reason), 0, 8) === 'https://')) {


+ 1
- 2
src/Module/Manifest.php View File

@ -10,8 +10,7 @@ class Manifest extends BaseModule
{
public static function rawContent(array $parameters = [])
{
$app = DI::app();
$config = $app->getConfig();
$config = DI::config();
$tpl = Renderer::getMarkupTemplate('manifest.tpl');


+ 13
- 25
src/Module/NodeInfo.php View File

@ -2,10 +2,8 @@
namespace Friendica\Module;
use Friendica\App;
use Friendica\BaseModule;
use Friendica\Core\Addon;
use Friendica\Core\System;
use Friendica\DI;
/**
@ -16,12 +14,10 @@ class NodeInfo extends BaseModule
{
public static function rawContent(array $parameters = [])
{
$app = DI::app();
if ($parameters['version'] == '1.0') {
self::printNodeInfo1($app);
self::printNodeInfo1();
} elseif ($parameters['version'] == '2.0') {
self::printNodeInfo2($app);
self::printNodeInfo2();
} else {
throw new \Friendica\Network\HTTPException\NotFoundException();
}
@ -30,13 +26,11 @@ class NodeInfo extends BaseModule
/**
* Return the supported services
*
* @param App $app
*
* @return array with supported services
*/
private static function getUsage(App $app)
private static function getUsage()
{
$config = $app->getConfig();
$config = DI::config();
$usage = [];
@ -56,11 +50,9 @@ class NodeInfo extends BaseModule
/**
* Return the supported services
*
* @param App $app
*
* @return array with supported services
*/
private static function getServices(App $app)
private static function getServices()
{
$services = [
'inbound' => [],
@ -117,12 +109,10 @@ class NodeInfo extends BaseModule
/**
* Print the nodeinfo version 1
*
* @param App $app
*/
private static function printNodeInfo1(App $app)
private static function printNodeInfo1()
{
$config = $app->getConfig();
$config = DI::config();
$nodeinfo = [
'version' => '1.0',
@ -156,9 +146,9 @@ class NodeInfo extends BaseModule
$nodeinfo['protocols']['outbound'][] = 'gnusocial';
}
$nodeinfo['usage'] = self::getUsage($app);
$nodeinfo['usage'] = self::getUsage();
$nodeinfo['services'] = self::getServices($app);
$nodeinfo['services'] = self::getServices();
$nodeinfo['metadata']['protocols'] = $nodeinfo['protocols'];
$nodeinfo['metadata']['protocols']['outbound'][] = 'atom1.0';
@ -180,12 +170,10 @@ class NodeInfo extends BaseModule
/**
* Print the nodeinfo version 2
*
* @param App $app
*/
private static function printNodeInfo2(App $app)
private static function printNodeInfo2()
{
$config = $app->getConfig();
$config = DI::config();
$imap = (function_exists('imap_open') && !$config->get('system', 'imap_disabled') && !$config->get('system', 'dfrn_only'));
@ -212,9 +200,9 @@ class NodeInfo extends BaseModule
$nodeinfo['protocols'][] = 'ostatus';
}
$nodeinfo['usage'] = self::getUsage($app);
$nodeinfo['usage'] = self::getUsage();
$nodeinfo['services'] = self::getServices($app);
$nodeinfo['services'] = self::getServices();
if (Addon::isEnabled('twitter')) {
$nodeinfo['services']['inbound'][] = 'twitter';


+ 1
- 1
src/Module/Register.php View File

@ -198,7 +198,7 @@ class Register extends BaseModule
$arr['blocked'] = $blocked;
$arr['verified'] = $verified;
$arr['language'] = L10nClass::detectLanguage($_SERVER, $_GET, $a->getConfig()->get('system', 'language'));
$arr['language'] = L10nClass::detectLanguage($_SERVER, $_GET, DI::config()->get('system', 'language'));
try {
$result = Model\User::create($arr);


+ 1
- 1
src/Module/Security/Login.php View File

@ -88,7 +88,7 @@ class Login extends BaseModule
}
$reg = false;
if ($register && intval($a->getConfig()->get('config', 'register_policy')) !== Register::CLOSED) {
if ($register && intval(DI::config()->get('config', 'register_policy')) !== Register::CLOSED) {
$reg = [
'title' => L10n::t('Create a New Account'),
'desc' => L10n::t('Register'),


+ 4
- 6
src/Module/Statistics.php View File

@ -4,23 +4,21 @@ namespace Friendica\Module;
use Friendica\BaseModule;
use Friendica\Core\Addon;
use Friendica\Core\System;
use Friendica\DI;
use Friendica\Network\HTTPException\NotFoundException;
class Statistics extends BaseModule
{
public static function init(array $parameters = [])
{
$config = DI::app()->getConfig();
if (!$config->get("system", "nodeinfo")) {
throw new \Friendica\Network\HTTPException\NotFoundException();
if (!DI::config()->get("system", "nodeinfo")) {
throw new NotFoundException();
}
}
public static function rawContent(array $parameters = [])
{
$config = DI::app()->getConfig();
$config = DI::config();
$logger = DI::app()->getLogger();
$registration_open =


+ 1
- 1
src/Module/Welcome.php View File

@ -14,7 +14,7 @@ class Welcome extends BaseModule
{
public static function content(array $parameters = [])
{
$config = DI::app()->getConfig();
$config = DI::config();
$mail_disabled = ((function_exists('imap_open') &&
(!$config->get('system', 'imap_disabled'))));


+ 1
- 1
src/Module/WellKnown/HostMeta.php View File

@ -17,7 +17,7 @@ class HostMeta extends BaseModule
public static function rawContent(array $parameters = [])
{
$app = DI::app();
$config = $app->getConfig();
$config = DI::config();
header('Content-type: text/xml');


+ 1
- 1
src/Module/WellKnown/XSocialRelay.php View File

@ -15,7 +15,7 @@ class XSocialRelay extends BaseModule
public static function rawContent(array $parameters = [])
{
$app = DI::app();
$config = $app->getConfig();
$config = DI::config();
$subscribe = $config->get('system', 'relay_subscribe', false);


Loading…
Cancel
Save