]> git.mxchange.org Git - friendica.git/blob - src/Core/Config/Capability/IManageConfigValues.php
Merge pull request #10918 from nupplaphil/feat/core_new_paradigm
[friendica.git] / src / Core / Config / Capability / IManageConfigValues.php
1 <?php
2 /**
3  * @copyright Copyright (C) 2010-2021, the Friendica project
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\Capability;
23
24 use Friendica\Core\Config\Exception\ConfigPersistenceException;
25 use Friendica\Core\Config\ValueObject\Cache;
26
27 /**
28  * Interface for accessing system-wide configurations
29  */
30 interface IManageConfigValues
31 {
32         /**
33          * Loads all configuration values of family into a cached storage.
34          *
35          * All configuration values of the system are stored in the cache.
36          *
37          * @param string $cat The category of the configuration value
38          *
39          * @return void
40          *
41          * @throws ConfigPersistenceException In case the persistence layer throws errors
42          */
43         public function load(string $cat = 'config');
44
45         /**
46          * Get a particular user's config variable given the category name
47          * ($cat) and a $key.
48          *
49          * Get a particular config value from the given category ($cat)
50          * and the $key from a cached storage either from the database or from the cache.
51          *
52          * @param string  $cat        The category of the configuration value
53          * @param string  $key           The configuration key to query
54          * @param mixed   $default_value optional, The value to return if key is not set (default: null)
55          * @param boolean $refresh       optional, If true the config is loaded from the db and not from the cache (default: false)
56          *
57          * @return mixed Stored value or null if it does not exist
58          *
59          * @throws ConfigPersistenceException In case the persistence layer throws errors
60          *
61          */
62         public function get(string $cat, string $key, $default_value = null, bool $refresh = false);
63
64         /**
65          * Sets a configuration value for system config
66          *
67          * Stores a config value ($value) in the category ($cat) under the key ($key)
68          *
69          * Note: Please do not store booleans - convert to 0/1 integer values!
70          *
71          * @param string $cat The category of the configuration value
72          * @param string $key    The configuration key to set
73          * @param mixed  $value  The value to store
74          *
75          * @return bool Operation success
76          *
77          * @throws ConfigPersistenceException In case the persistence layer throws errors
78          */
79         public function set(string $cat, string $key, $value): bool;
80
81         /**
82          * Deletes the given key from the system configuration.
83          *
84          * Removes the configured value from the stored cache in the cache and removes it from the database.
85          *
86          * @param string $cat The category of the configuration value
87          * @param string $key    The configuration key to delete
88          *
89          * @return bool
90          *
91          * @throws ConfigPersistenceException In case the persistence layer throws errors
92          *
93          */
94         public function delete(string $cat, string $key): bool;
95
96         /**
97          * Returns the Config Cache
98          *
99          * @return Cache
100          */
101         public function getCache(): Cache;
102 }