3 * User Configuration Class
5 * @file include/Core/PConfig.php
7 * @brief Contains the class with methods for user configuration
9 namespace Friendica\Core;
11 use Friendica\BaseObject;
12 use Friendica\Core\Config\PConfiguration;
15 * @brief Management of user configuration storage
17 * Please do not store booleans - convert to 0/1 integer values
18 * The PConfig::get() functions return boolean false for keys that are unset,
19 * and this could lead to subtle bugs.
21 class PConfig extends BaseObject
24 * @brief Loads all configuration values of a user's config family into a cached storage.
26 * @param int $uid The user_id
27 * @param string $cat The category of the configuration value
31 public static function load(int $uid, string $cat)
33 self::getClass(PConfiguration::class)->load($uid, $cat);
37 * @brief Get a particular user's config variable given the category name
40 * @param int $uid The user_id
41 * @param string $cat The category of the configuration value
42 * @param string $key The configuration key to query
43 * @param mixed $default_value optional, The value to return if key is not set (default: null)
44 * @param boolean $refresh optional, If true the config is loaded from the db and not from the cache (default: false)
46 * @return mixed Stored value or null if it does not exist
48 public static function get(int $uid, string $cat, string $key, $default_value = null, bool $refresh = false)
50 return self::getClass(PConfiguration::class)->get($uid, $cat, $key, $default_value, $refresh);
54 * @brief Sets a configuration value for a user
56 * @param int $uid The user_id
57 * @param string $cat The category of the configuration value
58 * @param string $key The configuration key to set
59 * @param mixed $value The value to store
61 * @return bool Operation success
63 public static function set(int $uid, string $cat, string $key, $value)
65 return self::getClass(PConfiguration::class)->set($uid, $cat, $key, $value);
69 * @brief Deletes the given key from the users's configuration.
71 * @param int $uid The user_id
72 * @param string $cat The category of the configuration value
73 * @param string $key The configuration key to delete
77 public static function delete(int $uid, string $cat, string $key)
79 return self::getClass(PConfiguration::class)->delete($uid, $cat, $key);