]> git.mxchange.org Git - friendica.git/blob - src/Core/Config/IConfig.php
Add "addon" console command to enable and disable addons
[friendica.git] / src / Core / Config / IConfig.php
1 <?php
2 /**
3  * @copyright Copyright (C) 2020, Friendica
4  *
5  * @license GNU AGPL version 3 or any later version
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU Affero General Public License as
9  * published by the Free Software Foundation, either version 3 of the
10  * License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU Affero General Public License for more details.
16  *
17  * You should have received a copy of the GNU Affero General Public License
18  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
19  *
20  */
21
22 namespace Friendica\Core\Config;
23
24 /**
25  * Interface for accessing system wide configurations
26  */
27 interface IConfig
28 {
29
30         /**
31          * Loads all configuration values of family into a cached storage.
32          *
33          * All configuration values of the system are stored in the cache ( @param string $cat The category of the configuration value
34          *
35          * @return void
36          */
37         function load(string $cat = 'config');
38
39         /**
40          * Get a particular user's config variable given the category name
41          * ($cat) and a $key.
42          *
43          * Get a particular config value from the given category ($cat)
44          * and the $key from a cached storage either from the $this->configAdapter
45          * (@see IConfigAdapter) or from the $this->configCache (@see ConfigCache).
46          *
47          * @param string  $cat        The category of the configuration value
48          * @param string  $key           The configuration key to query
49          * @param mixed   $default_value optional, The value to return if key is not set (default: null)
50          * @param boolean $refresh       optional, If true the config is loaded from the db and not from the cache (default: false)
51          *
52          * @return mixed Stored value or null if it does not exist
53          */
54         function get(string $cat, string $key, $default_value = null, bool $refresh = false);
55
56         /**
57          * Sets a configuration value for system config
58          *
59          * Stores a config value ($value) in the category ($cat) under the key ($key)
60          *
61          * Note: Please do not store booleans - convert to 0/1 integer values!
62          *
63          * @param string $cat The category of the configuration value
64          * @param string $key    The configuration key to set
65          * @param mixed  $value  The value to store
66          *
67          * @return bool Operation success
68          */
69         function set(string $cat, string $key, $value);
70
71         /**
72          * Deletes the given key from the system configuration.
73          *
74          * Removes the configured value from the stored cache in $this->configCache
75          * (@see ConfigCache) and removes it from the database (@see IConfigAdapter).
76          *
77          * @param string $cat The category of the configuration value
78          * @param string $key    The configuration key to delete
79          *
80          * @return bool
81          */
82         function delete(string $cat, string $key);
83
84         /**
85          * Returns the Config Cache
86          *
87          * @return Cache
88          */
89         function getCache();
90 }