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-adapter @see Adapter\IPConfigAdapter )
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(int $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 * (@param int $uid The user_id
68 * @param string $cat The category of the configuration value
69 * @param string $key The configuration key to query
70 * @param mixed $default_value optional, The value to return if key is not set (default: null)
71 * @param boolean $refresh optional, If true the config is loaded from the db and not from the cache (default: false)
73 * @return mixed Stored value or null if it does not exist
74 * @see IConfigAdapter ) or from the $this->configCache (@see PConfigCache ).
77 abstract public function get(int $uid, string $cat, string $key, $default_value = null, bool $refresh = false);
80 * Sets a configuration value for a user
82 * Stores a config value ($value) in the category ($family) under the key ($key)
83 * for the user_id $uid.
85 * @note Please do not store booleans - convert to 0/1 integer values!
87 * @param int $uid The user_id
88 * @param string $cat The category of the configuration value
89 * @param string $key The configuration key to set
90 * @param mixed $value The value to store
92 * @return bool Operation success
94 abstract public function set(int $uid, string $cat, string $key, $value);
97 * Deletes the given key from the users's configuration.
99 * Removes the configured value from the stored cache in $this->configCache
100 * (@param int $uid The user_id
102 * @param string $cat The category of the configuration value
103 * @param string $key The configuration key to delete
106 * @see ConfigCache ) and removes it from the database (@see IConfigAdapter )
107 * with the given $uid.
110 abstract public function delete(int $uid, string $cat, string $key);