3 namespace Friendica\Core\Config;
8 * This class is responsible for all system-wide configuration values in Friendica
9 * There are two types of storage
10 * - The Config-Files (loaded into the FileCache @see Cache\ConfigCache)
11 * - The Config-DB-Table (per Config-DB-model @see Model\Config\Config)
13 abstract class Configuration
16 * @var Cache\ConfigCache
18 protected $configCache;
21 * @var Model\Config\Config
23 protected $configModel;
26 * @param Cache\ConfigCache $configCache The configuration cache (based on the config-files)
27 * @param Model\Config\Config $configModel The configuration model
29 public function __construct(Cache\ConfigCache $configCache, Model\Config\Config $configModel)
31 $this->configCache = $configCache;
32 $this->configModel = $configModel;
36 * Returns the Config Cache
38 * @return Cache\ConfigCache
40 public function getCache()
42 return $this->configCache;
46 * @brief Loads all configuration values of family into a cached storage.
48 * All configuration values of the system are stored in the cache ( @see ConfigCache )
50 * @param string $cat The category of the configuration value
54 abstract public function load(string $cat = 'config');
57 * @brief Get a particular user's config variable given the category name
60 * Get a particular config value from the given category ($cat)
61 * and the $key from a cached storage either from the $this->configAdapter
62 * (@see IConfigAdapter) or from the $this->configCache (@see ConfigCache).
64 * @param string $cat The category of the configuration value
65 * @param string $key The configuration key to query
66 * @param mixed $default_value optional, The value to return if key is not set (default: null)
67 * @param boolean $refresh optional, If true the config is loaded from the db and not from the cache (default: false)
69 * @return mixed Stored value or null if it does not exist
71 abstract public function get(string $cat, string $key, $default_value = null, bool $refresh = false);
74 * @brief Sets a configuration value for system config
76 * Stores a config value ($value) in the category ($cat) under the key ($key)
78 * Note: Please do not store booleans - convert to 0/1 integer values!
80 * @param string $cat The category of the configuration value
81 * @param string $key The configuration key to set
82 * @param mixed $value The value to store
84 * @return bool Operation success
86 abstract public function set(string $cat, string $key, $value);
89 * @brief Deletes the given key from the system configuration.
91 * Removes the configured value from the stored cache in $this->configCache
92 * (@see ConfigCache) and removes it from the database (@see IConfigAdapter).
94 * @param string $cat The category of the configuration value
95 * @param string $key The configuration key to delete
99 abstract public function delete(string $cat, string $key);