4bd8eac264167269d411aa8b1071b72bb50fb690
[friendica.git/.git] / src / Core / Config / IConfigAdapter.php
1 <?php
2
3 namespace Friendica\Core\Config;
4
5 /**
6  *
7  * @author Hypolite Petovan <mrpetovan@gmail.com>
8  */
9 interface IConfigAdapter
10 {
11         /**
12          * @brief Loads all configuration values into a cached storage.
13          *
14          * All configuration values of the system are stored in global cache
15          * which is available under the global variable $a->config
16          *
17          * @param string  $cat The category of the configuration values to load
18          *
19          * @return void
20          */
21         public function load($cat = "config");
22
23         /**
24          * @brief Get a particular user's config variable given the category name
25          * ($family) and a key.
26          *
27          * Get a particular config value from the given category ($family)
28          * and the $key from a cached storage in $a->config[$uid].
29          * $instore is only used by the set_config function
30          * to determine if the key already exists in the DB
31          * If a key is found in the DB but doesn't exist in
32          * local config cache, pull it into the cache so we don't have
33          * to hit the DB again for this item.
34          *
35          * @param string  $cat           The category of the configuration value
36          * @param string  $k             The configuration key to query
37          * @param mixed   $default_value optional, The value to return if key is not set (default: null)
38          * @param boolean $refresh       optional, If true the config is loaded from the db and not from the cache (default: false)
39          *
40          * @return mixed Stored value or null if it does not exist
41          */
42         public function get($cat, $k, $default_value = null, $refresh = false);
43
44         /**
45          * @brief Sets a configuration value for system config
46          *
47          * Stores a config value ($value) in the category ($family) under the key ($key)
48          * for the user_id $uid.
49          *
50          * Note: Please do not store booleans - convert to 0/1 integer values!
51          *
52          * @param string $family The category of the configuration value
53          * @param string $key    The configuration key to set
54          * @param mixed  $value  The value to store
55          *
56          * @return bool Operation success
57          */
58         public function set($cat, $k, $value);
59
60         /**
61          * @brief Deletes the given key from the system configuration.
62          *
63          * Removes the configured value from the stored cache in $a->config
64          * and removes it from the database.
65          *
66          * @param string $cat The category of the configuration value
67          * @param string $k   The configuration key to delete
68          *
69          * @return mixed
70          */
71         public function delete($cat, $k);
72 }