]> git.mxchange.org Git - friendica.git/commitdiff
Refactor dynamic App::getConfig() to static DI::config()
authornupplaPhil <admin@philipp.info>
Sun, 15 Dec 2019 22:44:33 +0000 (23:44 +0100)
committernupplaPhil <admin@philipp.info>
Sun, 29 Dec 2019 19:17:40 +0000 (20:17 +0100)
21 files changed:
src/App.php
src/Core/Search.php
src/Core/Worker.php
src/Model/Nodeinfo.php
src/Module/Admin/Summary.php
src/Module/BaseSearchModule.php
src/Module/Bookmarklet.php
src/Module/Directory.php
src/Module/Friendica.php
src/Module/Help.php
src/Module/Home.php
src/Module/Invite.php
src/Module/Maintenance.php
src/Module/Manifest.php
src/Module/NodeInfo.php
src/Module/Register.php
src/Module/Security/Login.php
src/Module/Statistics.php
src/Module/Welcome.php
src/Module/WellKnown/HostMeta.php
src/Module/WellKnown/XSocialRelay.php

index 3ea7d05f0c39bd27c6ee9894b16c0552cde9f9a9..6f1045ada5e67dd7f452024b251699962367187b 100644 (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
         *
index c1c80091f0df693328263b789edb237ec2e63327..ab06a51a7d7d9c522d2a492257e8e4b60984ca02 100644 (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;
index b451b11ca502b258dfed513be96afe774d7bd0f0..a87fef07713b7055f4ccfb6e825e4d241254d6ad 100644 (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.
index 29fa00aa1959c5f288a67625dae97de75f6aaf9f..58a9e45447a0d4a79be8c9167576cbbb36e85da9 100644 (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.
index 25097d533e05e7ff46c3d405285996bed3e5e145..60b35289c9427ba559fd572711e98bcc7ef541af 100644 (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.', [
index 0fa3eb5d631cb16f368b8ebc1962a2bd1abb0816..efedca92af3cc543b88ed5f82192d6af1742d193 100644 (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;
 
index bae0e7c4d4ed3bbfa76ce8b874de5e2301ed5e18..93f790a37d7be77642a9a6a187d552bd77960a27 100644 (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>';
index e38810e8ec25f62333b7b9f50ab8be034f2afc12..4ad9438fb922d8ca47125cd43598cf336f2f1b1e 100644 (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())) {
index 2eb2940ed36eede22cf4c1435d99640fdd501c5e..4f33fea43a2aa98f2e348a90845683826a2ab077 100644 (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',
index 0ff4cc68b04522e0bb0066ee3b1deb387b0dbe34..7c1ecd74650b480661adbbf522da1cd30a7ed932 100644 (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
index eb122b05271bd5e362cd86ee3003cd3a8680b393..f5032f7c30ddaecd93b5a048bccef357eb23b733 100644 (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 = [];
index 9261ea703c5462756f782b82f6862c4d38e0985b..52d9bbcea39ac12c834f3042d631fc072bb30f31 100644 (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;
 
index 35a6df629532d07ef9c486d835f53d1760f626a9..bee9ab53f505524d2cf89db4039e0d37ec8264d0 100644 (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://')) {
index de1dfc915030aaab1d3f6a8c1c343c93fbde50ff..a7ef344e4d8c30a97948e371a183a39b687c453d 100644 (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');
 
index 5c5b573b229325960d8256b468872439f70aef9f..a62687de1b58a30ea903a52647456779423bda18 100644 (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';
index d079c5c420bcb9b5266a6b330e129fd9cf38bef4..9a6df2f634ee113ecd65f148a1d4df526cd66e60 100644 (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);
index dc129e8f66c6629e6c88c3d54f52eb53f5e99577..a049abc882fa3ac92a92f7c58a1ebd59123492c1 100644 (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'),
index 1fe129011ae1bca0bee290b741fe8d7f6de39b52..11cbdf53afb0f33ec8279cf09ae51c3fc0d32bd1 100644 (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 =
index e62c5a62db6d8b932c21b5beca617f755c43c400..6182146337ee44e617082304e916f5d70a844169 100644 (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'))));
index 3b03567d71db4e040270a49ec48e41b447bb1e82..aec95c2a2766e37c8f7aa996968ceb9f7b59b570 100644 (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');
 
index 2ddac3836d82b7067329155c7b23d65c236413ff..38a9e12435091263722e899608ae87522ead71b3 100644 (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);