3 * @copyright Copyright (C) 2010-2023, the Friendica project
5 * @license GNU AGPL version 3 or any later version
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.
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.
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/>.
22 namespace Friendica\Core\Config\Capability;
24 use Friendica\Core\Config\Exception\ConfigPersistenceException;
25 use Friendica\Core\Config\Util\ConfigFileManager;
26 use Friendica\Core\Config\ValueObject\Cache;
29 * Interface for accessing system-wide configurations
31 interface IManageConfigValues
34 * Reloads all configuration values from the persistence layer
36 * All configuration values of the system are stored in the cache.
40 * @throws ConfigPersistenceException In case the persistence layer throws errors
42 public function reload();
45 * Get a particular user's config variable given the category name
48 * Get a particular config value from the given category ($cat)
50 * @param string $cat The category of the configuration value
51 * @param ?string $key The configuration key to query (if null, the whole array at the category will get returned)
52 * @param mixed $default_value Deprecated, use `Config->get($cat, $key, null, $refresh) ?? $default_value` instead
54 * @return mixed Stored value or null if it does not exist
56 * @throws ConfigPersistenceException In case the persistence layer throws errors
59 public function get(string $cat, string $key = null, $default_value = null);
62 * Returns true, if the current config can be changed
64 * @param string $cat The category of the configuration value
65 * @param string $key The configuration key to query
67 * @return bool true, if writing is possible
69 public function isWritable(string $cat, string $key): bool;
72 * Sets a configuration value for system config
74 * Stores a config value ($value) in the category ($cat) under the key ($key)
76 * Note: Please do not store booleans - convert to 0/1 integer values!
78 * @param string $cat The category of the configuration value
79 * @param string $key The configuration key to set
80 * @param mixed $value The value to store
82 * @return bool Operation success
84 * @throws ConfigPersistenceException In case the persistence layer throws errors
86 public function set(string $cat, string $key, $value): bool;
89 * Creates a transactional config value store, which is used to set a bunch of values at once
91 * It relies on the current instance, so after save(), the values of this config class will get altered at once too.
93 * @return ISetConfigValuesTransactionally
95 public function beginTransaction(): ISetConfigValuesTransactionally;
98 * Deletes the given key from the system configuration.
100 * Removes the configured value from the stored cache in the cache and removes it from the database.
102 * @param string $cat The category of the configuration value
103 * @param string $key The configuration key to delete
107 * @throws ConfigPersistenceException In case the persistence layer throws errors
110 public function delete(string $cat, string $key): bool;
113 * Returns the Config Cache
117 public function getCache(): Cache;