]> git.mxchange.org Git - friendica.git/blob - src/Core/Config/Capability/IManageConfigValues.php
88fa96314ba7056038808ecd48c310d17957ef26
[friendica.git] / src / Core / Config / Capability / IManageConfigValues.php
1 <?php
2 /**
3  * @copyright Copyright (C) 2010-2023, 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          * Reloads all configuration values (from filesystem and environment variables)
34          *
35          * All configuration values of the system are stored in the cache.
36          *
37          * @return void
38          *
39          * @throws ConfigPersistenceException In case the persistence layer throws errors
40          */
41         public function reload();
42
43         /**
44          * Get a particular user's config variable given the category name
45          * ($cat) and a $key.
46          *
47          * Get a particular config value from the given category ($cat)
48          *
49          * @param string  $cat        The category of the configuration value
50          * @param string  $key           The configuration key to query
51          * @param mixed   $default_value Deprecated, use `Config->get($cat, $key, null, $refresh) ?? $default_value` instead
52          *
53          * @return mixed Stored value or null if it does not exist
54          *
55          * @throws ConfigPersistenceException In case the persistence layer throws errors
56          *
57          */
58         public function get(string $cat, string $key, $default_value = null);
59
60         /**
61          * Sets a configuration value for system config
62          *
63          * Stores a config value ($value) in the category ($cat) under the key ($key)
64          *
65          * Note: Please do not store booleans - convert to 0/1 integer values!
66          *
67          * @param string $cat The category of the configuration value
68          * @param string $key    The configuration key to set
69          * @param mixed  $value  The value to store
70          * @param bool   $autosave If true, implicit save the value
71          *
72          * @return bool Operation success
73          *
74          * @throws ConfigPersistenceException In case the persistence layer throws errors
75          */
76         public function set(string $cat, string $key, $value, bool $autosave = true): bool;
77
78         /**
79          * Save back the overridden values of the config cache
80          *
81          * @throws ConfigPersistenceException In case the persistence layer throws errors
82          */
83         public function save();
84
85         /**
86          * Deletes the given key from the system configuration.
87          *
88          * Removes the configured value from the stored cache in the cache and removes it from the database.
89          *
90          * @param string $cat The category of the configuration value
91          * @param string $key    The configuration key to delete
92          * @param bool   $autosave If true, implicit save the value
93          *
94          * @return bool
95          *
96          * @throws ConfigPersistenceException In case the persistence layer throws errors
97          *
98          */
99         public function delete(string $cat, string $key, bool $autosave = true): bool;
100
101         /**
102          * Returns the Config Cache
103          *
104          * @return Cache
105          */
106         public function getCache(): Cache;
107 }