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