2) Refactor App->config[] into Core\PConfig

This commit is contained in:
Philipp Holzer 2019-02-03 19:04:41 +01:00
parent be6b229534
commit d43a8184f4
No known key found for this signature in database
GPG key ID: 517BE60E2CE5C8A5
7 changed files with 98 additions and 98 deletions

View file

@ -3,7 +3,7 @@
namespace Friendica\Core\Config;
use Exception;
use Friendica\BaseObject;
use Friendica\Core\PConfig;
use Friendica\Database\DBA;
/**
@ -13,7 +13,7 @@ use Friendica\Database\DBA;
*
* @author Hypolite Petovan <hypolite@mrpetovan.com>
*/
class PreloadPConfigAdapter extends BaseObject implements IPConfigAdapter
class PreloadPConfigAdapter implements IPConfigAdapter
{
private $config_loaded = false;
@ -34,7 +34,7 @@ class PreloadPConfigAdapter extends BaseObject implements IPConfigAdapter
$pconfigs = DBA::select('pconfig', ['cat', 'v', 'k'], ['uid' => $uid]);
while ($pconfig = DBA::fetch($pconfigs)) {
self::getApp()->setPConfigValue($uid, $pconfig['cat'], $pconfig['k'], $pconfig['v']);
PConfig::setPConfigValue($uid, $pconfig['cat'], $pconfig['k'], $pconfig['v']);
}
DBA::close($pconfigs);
@ -50,13 +50,13 @@ class PreloadPConfigAdapter extends BaseObject implements IPConfigAdapter
if ($refresh) {
$config = DBA::selectFirst('pconfig', ['v'], ['uid' => $uid, 'cat' => $cat, 'k' => $k]);
if (DBA::isResult($config)) {
self::getApp()->setPConfigValue($uid, $cat, $k, $config['v']);
PConfig::setPConfigValue($uid, $cat, $k, $config['v']);
} else {
self::getApp()->deletePConfigValue($uid, $cat, $k);
PConfig::deletePConfigValue($uid, $cat, $k);
}
}
$return = self::getApp()->getPConfigValue($uid, $cat, $k, $default_value);
$return = PConfig::getPConfigValue($uid, $cat, $k, $default_value);
return $return;
}
@ -71,11 +71,11 @@ class PreloadPConfigAdapter extends BaseObject implements IPConfigAdapter
// The exception are array values.
$compare_value = !is_array($value) ? (string)$value : $value;
if (self::getApp()->getPConfigValue($uid, $cat, $k) === $compare_value) {
if (PConfig::getPConfigValue($uid, $cat, $k) === $compare_value) {
return true;
}
self::getApp()->setPConfigValue($uid, $cat, $k, $value);
PConfig::setPConfigValue($uid, $cat, $k, $value);
// manage array value
$dbvalue = is_array($value) ? serialize($value) : $value;
@ -94,7 +94,7 @@ class PreloadPConfigAdapter extends BaseObject implements IPConfigAdapter
$this->load($uid, $cat);
}
self::getApp()->deletePConfigValue($uid, $cat, $k);
PConfig::deletePConfigValue($uid, $cat, $k);
$result = DBA::delete('pconfig', ['uid' => $uid, 'cat' => $cat, 'k' => $k]);