3 namespace Friendica\Core\Config;
8 * This class is responsible for the user-specific configuration values in Friendica
9 * The values are set through the Config-DB-Table (per Config-DB-model @see Model\Config\PConfig)
11 * The configuration cache (@see Cache\PConfigCache ) is used for temporary caching of database calls. This will
12 * increase the performance.
14 abstract class PConfiguration
17 * @var Cache\PConfigCache
19 protected $configCache;
22 * @var Model\Config\PConfig
24 protected $configModel;
27 * @param Cache\PConfigCache $configCache The configuration cache
28 * @param Model\Config\PConfig $configModel The configuration model
30 public function __construct(Cache\PConfigCache $configCache, Model\Config\PConfig $configModel)
32 $this->configCache = $configCache;
33 $this->configModel = $configModel;
37 * Returns the Config Cache
39 * @return Cache\PConfigCache
41 public function getCache()
43 return $this->configCache;
47 * Loads all configuration values of a user's config family into a cached storage.
49 * All configuration values of the given user are stored with the $uid in
50 * the cache ( @param int $uid The user_id
52 * @param string $cat The category of the configuration value
58 abstract public function load($uid, string $cat = 'config');
61 * Get a particular user's config variable given the category name
64 * Get a particular user's config value from the given category ($cat)
65 * and the $key with the $uid from a cached storage either from the $this->configAdapter
66 * (@see IConfigAdapter ) or from the $this->configCache (@see PConfigCache ).
68 * @param int $uid The user_id
69 * @param string $cat The category of the configuration value
70 * @param string $key The configuration key to query
71 * @param mixed $default_value optional, The value to return if key is not set (default: null)
72 * @param boolean $refresh optional, If true the config is loaded from the db and not from the cache (default: false)
74 * @return mixed Stored value or null if it does not exist
76 abstract public function get($uid, string $cat, string $key, $default_value = null, bool $refresh = false);
79 * Sets a configuration value for a user
81 * Stores a config value ($value) in the category ($family) under the key ($key)
82 * for the user_id $uid.
84 * @note Please do not store booleans - convert to 0/1 integer values!
86 * @param int $uid The user_id
87 * @param string $cat The category of the configuration value
88 * @param string $key The configuration key to set
89 * @param mixed $value The value to store
91 * @return bool Operation success
93 abstract public function set($uid, string $cat, string $key, $value);
96 * Deletes the given key from the users's configuration.
98 * Removes the configured value from the stored cache in $this->configCache
99 * (@see ConfigCache ) and removes it from the database (@see IConfigAdapter )
100 * with the given $uid.
102 * @param int $uid The user_id
103 * @param string $cat The category of the configuration value
104 * @param string $key The configuration key to delete
108 abstract public function delete($uid, string $cat, string $key);