]> git.mxchange.org Git - friendica.git/blob - src/Core/Config.php
Merge branch 'master' 2019.12 into develop
[friendica.git] / src / Core / Config.php
1 <?php
2 /**
3  * System Configuration Class
4  *
5  * @file include/Core/Config.php
6  *
7  * @brief Contains the class with methods for system configuration
8  */
9 namespace Friendica\Core;
10
11 use Friendica\BaseObject;
12 use Friendica\Core\Config\Configuration;
13
14 /**
15  * @brief Arbitrary system configuration storage
16  *
17  * Note:
18  * If we ever would decide to return exactly the variable type as entered,
19  * we will have fun with the additional features. :-)
20  */
21 class Config extends BaseObject
22 {
23         /**
24          * @brief Loads all configuration values of family into a cached storage.
25          *
26          * @param string $cat The category of the configuration value
27          *
28          * @return void
29          */
30         public static function load($cat = "config")
31         {
32                 self::getClass(Configuration::class)->load($cat);
33         }
34
35         /**
36          * @brief Get a particular user's config variable given the category name
37          * ($family) and a key.
38          *
39          * @param string  $cat        The category of the configuration value
40          * @param string  $key           The configuration key to query
41          * @param mixed   $default_value optional, The value to return if key is not set (default: null)
42          * @param boolean $refresh       optional, If true the config is loaded from the db and not from the cache (default: false)
43          *
44          * @return mixed Stored value or null if it does not exist
45          */
46         public static function get($cat, $key, $default_value = null, $refresh = false)
47         {
48                 return self::getClass(Configuration::class)->get($cat, $key, $default_value, $refresh);
49         }
50
51         /**
52          * @brief Sets a configuration value for system config
53          *
54          * Stores a config value ($value) in the category ($cat) under the key ($key)
55          *
56          * Note: Please do not store booleans - convert to 0/1 integer values!
57          *
58          * @param string $cat The category of the configuration value
59          * @param string $key    The configuration key to set
60          * @param mixed  $value  The value to store
61          *
62          * @return bool Operation success
63          */
64         public static function set($cat, $key, $value)
65         {
66                 return self::getClass(Configuration::class)->set($cat, $key, $value);
67         }
68
69         /**
70          * @brief Deletes the given key from the system configuration.
71          *
72          * @param string $cat The category of the configuration value
73          * @param string $key    The configuration key to delete
74          *
75          * @return bool
76          */
77         public static function delete($cat, $key)
78         {
79                 return self::getClass(Configuration::class)->delete($cat, $key);
80         }
81 }