1
0
Fork 0

Merge pull request #8142 from nupplaphil/task/di_config

CleanUp Config namespace
This commit is contained in:
Hypolite Petovan 2020-01-19 22:22:57 -05:00 committed by GitHub
commit 04d620fc2f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
207 changed files with 1276 additions and 1439 deletions

View file

@ -4,10 +4,10 @@ namespace Friendica\Util;
use Exception;
use Friendica\Core\Addon;
use Friendica\Core\Config\Cache\ConfigCache;
use Friendica\Core\Config\Cache;
/**
* The ConfigFileLoader loads config-files and stores them in a ConfigCache ( @see ConfigCache )
* The ConfigFileLoader loads config-files and stores them in a ConfigCache ( @see Cache )
*
* It is capable of loading the following config files:
* - *.config.php (current)
@ -77,12 +77,12 @@ class ConfigFileLoader
* First loads the default value for all the configuration keys, then the legacy configuration files, then the
* expected local.config.php
*
* @param ConfigCache $config The config cache to load to
* @param bool $raw Setup the raw config format
* @param Cache $config The config cache to load to
* @param bool $raw Setup the raw config format
*
* @throws Exception
*/
public function setupCache(ConfigCache $config, $raw = false)
public function setupCache(Cache $config, $raw = false)
{
// Load static config files first, the order is important
$config->load($this->loadStaticConfig('defaults'));
@ -128,13 +128,13 @@ class ConfigFileLoader
/**
* Tries to load the specified core-configuration into the config cache.
*
* @param ConfigCache $config The Config cache
* @param Cache $config The Config cache
*
* @return array The config array (empty if no config found)
*
* @throws Exception if the configuration file isn't readable
*/
private function loadCoreConfig(ConfigCache $config)
private function loadCoreConfig(Cache $config)
{
// try to load legacy ini-files first
foreach ($this->getConfigFiles(true) as $configFile) {

View file

@ -6,10 +6,10 @@ namespace Friendica\Util;
use ASN_BASE;
use ASNValue;
use Friendica\Core\Config;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\System;
use Friendica\DI;
/**
* Crypto class
@ -240,7 +240,7 @@ class Crypto
'encrypt_key' => false
];
$conf = Config::get('system', 'openssl_conf_file');
$conf = DI::config()->get('system', 'openssl_conf_file');
if ($conf) {
$openssl_options['config'] = $conf;
}

View file

@ -4,7 +4,6 @@
*/
namespace Friendica\Util;
use Friendica\Core\Config;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\DI;
@ -81,7 +80,7 @@ class Emailer
$multipartMessageBody .=
"--" . $mimeBoundary . "--\n"; // message ending
if (Config::get("system", "sendmail_params", true)) {
if (DI::config()->get("system", "sendmail_params", true)) {
$sendmail_params = '-f ' . $params['fromEmail'];
} else {
$sendmail_params = null;

View file

@ -34,7 +34,6 @@
namespace Friendica\Util;
use Friendica\Core\Config;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\User;
@ -50,7 +49,7 @@ class ExAuth
*/
public function __construct()
{
$this->bDebug = (int) Config::get('jabber', 'debug');
$this->bDebug = (int) DI::config()->get('jabber', 'debug');
openlog('auth_ejabberd', LOG_PID, LOG_USER);
@ -305,7 +304,7 @@ class ExAuth
$this->host = $host;
$lockpath = Config::get('jabber', 'lockpath');
$lockpath = DI::config()->get('jabber', 'lockpath');
if (is_null($lockpath)) {
$this->writeLog(LOG_INFO, 'No lockpath defined.');
return;

View file

@ -6,8 +6,8 @@
namespace Friendica\Util;
use Friendica\Database\DBA;
use Friendica\Core\Config;
use Friendica\Core\Logger;
use Friendica\DI;
use Friendica\Model\User;
use Friendica\Model\APContact;
@ -233,7 +233,7 @@ class HTTPSignature
$iv = $key = $alg = $data = null;
if (!$prvkey) {
$prvkey = Config::get('system', 'prvkey');
$prvkey = DI::config()->get('system', 'prvkey');
}
$matches = [];

View file

@ -6,7 +6,6 @@ namespace Friendica\Util;
use DOMDocument;
use DomXPath;
use Friendica\Core\Config;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\System;
@ -151,7 +150,7 @@ class Network
@curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
@curl_setopt($ch, CURLOPT_USERAGENT, $a->getUserAgent());
$range = intval(Config::get('system', 'curl_range_bytes', 0));
$range = intval(DI::config()->get('system', 'curl_range_bytes', 0));
if ($range > 0) {
@curl_setopt($ch, CURLOPT_RANGE, '0-' . $range);
@ -173,33 +172,33 @@ class Network
if (!empty($opts['timeout'])) {
@curl_setopt($ch, CURLOPT_TIMEOUT, $opts['timeout']);
} else {
$curl_time = Config::get('system', 'curl_timeout', 60);
$curl_time = DI::config()->get('system', 'curl_timeout', 60);
@curl_setopt($ch, CURLOPT_TIMEOUT, intval($curl_time));
}
// by default we will allow self-signed certs
// but you can override this
$check_cert = Config::get('system', 'verifyssl');
$check_cert = DI::config()->get('system', 'verifyssl');
@curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, (($check_cert) ? true : false));
if ($check_cert) {
@curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
}
$proxy = Config::get('system', 'proxy');
$proxy = DI::config()->get('system', 'proxy');
if (strlen($proxy)) {
@curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1);
@curl_setopt($ch, CURLOPT_PROXY, $proxy);
$proxyuser = @Config::get('system', 'proxyuser');
$proxyuser = @DI::config()->get('system', 'proxyuser');
if (strlen($proxyuser)) {
@curl_setopt($ch, CURLOPT_PROXYUSERPWD, $proxyuser);
}
}
if (Config::get('system', 'ipv4_resolve', false)) {
if (DI::config()->get('system', 'ipv4_resolve', false)) {
curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
}
@ -273,14 +272,14 @@ class Network
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
curl_setopt($ch, CURLOPT_USERAGENT, $a->getUserAgent());
if (Config::get('system', 'ipv4_resolve', false)) {
if (DI::config()->get('system', 'ipv4_resolve', false)) {
curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
}
if (intval($timeout)) {
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
} else {
$curl_time = Config::get('system', 'curl_timeout', 60);
$curl_time = DI::config()->get('system', 'curl_timeout', 60);
curl_setopt($ch, CURLOPT_TIMEOUT, intval($curl_time));
}
@ -288,19 +287,19 @@ class Network
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
}
$check_cert = Config::get('system', 'verifyssl');
$check_cert = DI::config()->get('system', 'verifyssl');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, (($check_cert) ? true : false));
if ($check_cert) {
@curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
}
$proxy = Config::get('system', 'proxy');
$proxy = DI::config()->get('system', 'proxy');
if (strlen($proxy)) {
curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1);
curl_setopt($ch, CURLOPT_PROXY, $proxy);
$proxyuser = Config::get('system', 'proxyuser');
$proxyuser = DI::config()->get('system', 'proxyuser');
if (strlen($proxyuser)) {
curl_setopt($ch, CURLOPT_PROXYUSERPWD, $proxyuser);
}
@ -368,7 +367,7 @@ class Network
*/
public static function isUrlValid(string $url)
{
if (Config::get('system', 'disable_url_validation')) {
if (DI::config()->get('system', 'disable_url_validation')) {
return $url;
}
@ -399,7 +398,7 @@ class Network
*/
public static function isEmailDomainValid(string $addr)
{
if (Config::get('system', 'disable_email_validation')) {
if (DI::config()->get('system', 'disable_email_validation')) {
return true;
}
@ -436,7 +435,7 @@ class Network
return false;
}
$str_allowed = Config::get('system', 'allowed_sites');
$str_allowed = DI::config()->get('system', 'allowed_sites');
if (! $str_allowed) {
return true;
}
@ -480,7 +479,7 @@ class Network
return false;
}
$domain_blocklist = Config::get('system', 'blocklist', []);
$domain_blocklist = DI::config()->get('system', 'blocklist', []);
if (!$domain_blocklist) {
return false;
}
@ -511,7 +510,7 @@ class Network
return false;
}
$str_allowed = Config::get('system', 'allowed_email', '');
$str_allowed = DI::config()->get('system', 'allowed_email', '');
if (empty($str_allowed)) {
return true;
}

View file

@ -2,8 +2,8 @@
namespace Friendica\Util;
use Friendica\Core\Config\Cache\ConfigCache;
use Friendica\Core\Config\IConfiguration;
use Friendica\Core\Config\Cache;
use Friendica\Core\Config\IConfig;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\ContainerInterface;
use Psr\Container\NotFoundExceptionInterface;
@ -47,18 +47,18 @@ class Profiler implements ContainerInterface
/**
* Updates the enabling of the current profiler
*
* @param IConfiguration $config
* @param IConfig $config
*/
public function update(IConfiguration $config)
public function update(IConfig $config)
{
$this->enabled = $config->get('system', 'profiler');
$this->rendertime = $config->get('rendertime', 'callstack');
}
/**
* @param ConfigCache $configCache The configuration cache
* @param Cache $configCache The configuration cache
*/
public function __construct(ConfigCache $configCache)
public function __construct(Cache $configCache)
{
$this->enabled = $configCache->get('system', 'profiler');
$this->rendertime = $configCache->get('rendertime', 'callstack');

View file

@ -2,7 +2,6 @@
namespace Friendica\Util;
use Friendica\Core\Config;
use Friendica\DI;
/**
@ -80,7 +79,7 @@ class Proxy
}
// Is the proxy disabled?
if (Config::get('system', 'proxy_disabled')) {
if (DI::config()->get('system', 'proxy_disabled')) {
return $url;
}