mirror of
https://github.com/friendica/friendica
synced 2025-05-01 03:04:23 +02:00
1) Refactor App->config[] into Core\Config
This commit is contained in:
parent
82f713cb7f
commit
be6b229534
11 changed files with 191 additions and 177 deletions
|
@ -3,7 +3,7 @@
|
|||
namespace Friendica\Core\Config;
|
||||
|
||||
use Exception;
|
||||
use Friendica\BaseObject;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Database\DBA;
|
||||
|
||||
/**
|
||||
|
@ -13,7 +13,7 @@ use Friendica\Database\DBA;
|
|||
*
|
||||
* @author Hypolite Petovan <hypolite@mrpetovan.com>
|
||||
*/
|
||||
class PreloadConfigAdapter extends BaseObject implements IConfigAdapter
|
||||
class PreloadConfigAdapter implements IConfigAdapter
|
||||
{
|
||||
private $config_loaded = false;
|
||||
|
||||
|
@ -30,7 +30,7 @@ class PreloadConfigAdapter extends BaseObject implements IConfigAdapter
|
|||
|
||||
$configs = DBA::select('config', ['cat', 'v', 'k']);
|
||||
while ($config = DBA::fetch($configs)) {
|
||||
self::getApp()->setConfigValue($config['cat'], $config['k'], $config['v']);
|
||||
Config::setConfigValue($config['cat'], $config['k'], $config['v']);
|
||||
}
|
||||
DBA::close($configs);
|
||||
|
||||
|
@ -42,11 +42,11 @@ class PreloadConfigAdapter extends BaseObject implements IConfigAdapter
|
|||
if ($refresh) {
|
||||
$config = DBA::selectFirst('config', ['v'], ['cat' => $cat, 'k' => $k]);
|
||||
if (DBA::isResult($config)) {
|
||||
self::getApp()->setConfigValue($cat, $k, $config['v']);
|
||||
Config::setConfigValue($cat, $k, $config['v']);
|
||||
}
|
||||
}
|
||||
|
||||
$return = self::getApp()->getConfigValue($cat, $k, $default_value);
|
||||
$return = Config::getConfigValue($cat, $k, $default_value);
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
@ -58,11 +58,11 @@ class PreloadConfigAdapter extends BaseObject implements IConfigAdapter
|
|||
// The exception are array values.
|
||||
$compare_value = !is_array($value) ? (string)$value : $value;
|
||||
|
||||
if (self::getApp()->getConfigValue($cat, $k) === $compare_value) {
|
||||
if (Config::getConfigValue($cat, $k) === $compare_value) {
|
||||
return true;
|
||||
}
|
||||
|
||||
self::getApp()->setConfigValue($cat, $k, $value);
|
||||
Config::setConfigValue($cat, $k, $value);
|
||||
|
||||
// manage array value
|
||||
$dbvalue = is_array($value) ? serialize($value) : $value;
|
||||
|
@ -77,7 +77,7 @@ class PreloadConfigAdapter extends BaseObject implements IConfigAdapter
|
|||
|
||||
public function delete($cat, $k)
|
||||
{
|
||||
self::getApp()->deleteConfigValue($cat, $k);
|
||||
Config::deleteConfigValue($cat, $k);
|
||||
|
||||
$result = DBA::delete('config', ['cat' => $cat, 'k' => $k]);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue