*/
namespace Friendica\Core;
-use Friendica\Core\Config\IPConfigCache;
-
/**
* @brief Management of user configuration storage
* Note:
class PConfig
{
/**
- * @var \Friendica\Core\Config\IPConfigAdapter
+ * @var Config\IPConfigAdapter
*/
private static $adapter;
/**
- * @var IPConfigCache
+ * @var Config\IPConfigCache
*/
- private static $config;
+ private static $cache;
/**
* Initialize the config with only the cache
*
- * @param IPConfigCache $config The configuration cache
+ * @param Config\IPConfigCache $cache The configuration cache
*/
- public static function init($config)
+ public static function init(Config\IPConfigCache $cache)
{
- self::$config = $config;
+ self::$cache = $cache;
}
/**
* Add the adapter for DB-backend
*
- * @param $adapter
+ * @param Config\IPConfigAdapter $adapter
*/
- public static function setAdapter($adapter)
+ public static function setAdapter(Config\IPConfigAdapter $adapter)
{
self::$adapter = $adapter;
}
/**
* @brief Loads all configuration values of a user's config family into a cached storage.
*
- * All configuration values of the given user are stored in global cache
- * which is available under the global variable self::$config[$uid].
+ * All configuration values of the given user are stored with the $uid in
+ * the cache ( @see IPConfigCache )
*
* @param string $uid The user_id
* @param string $family The category of the configuration value
*
* @return void
- * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function load($uid, $family)
{
* ($family) and a key.
*
* Get a particular user's config value from the given category ($family)
- * and the $key from a cached storage in self::$config[$uid].
+ * and the $key with the $uid from a cached storage either from the self::$adapter
+ * (@see IConfigAdapter ) or from the static::$cache (@see IConfigCache ).
*
* @param string $uid The user_id
* @param string $family The category of the configuration value
public static function get($uid, $family, $key, $default_value = null, $refresh = false)
{
if (!isset(self::$adapter)) {
- return self::$config->getP($uid, $family, $key, $default_value);
+ return self::$cache->getP($uid, $family, $key, $default_value);
}
return self::$adapter->get($uid, $family, $key, $default_value, $refresh);
public static function set($uid, $family, $key, $value)
{
if (!isset(self::$adapter)) {
- return self::$config->setP($uid, $family, $key, $value);
+ return self::$cache->setP($uid, $family, $key, $value);
}
return self::$adapter->set($uid, $family, $key, $value);
/**
* @brief Deletes the given key from the users's configuration.
*
- * Removes the configured value from the stored cache in self::$config[$uid]
- * and removes it from the database.
+ * Removes the configured value from the stored cache in self::$config
+ * (@see ConfigCache ) and removes it from the database (@see IConfigAdapter )
+ * with the given $uid.
*
* @param string $uid The user_id
* @param string $family The category of the configuration value
* @param string $key The configuration key to delete
*
* @return mixed
- * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function delete($uid, $family, $key)
{
if (!isset(self::$adapter)) {
- return self::$config->deleteP($uid, $family, $key);
+ return self::$cache->deleteP($uid, $family, $key);
}
return self::$adapter->delete($uid, $family, $key);