]> git.mxchange.org Git - friendica.git/blob - src/Core/Config/Capability/IManageConfigValues.php
Drop UpdateContact worker task if contact is blocked
[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\Util\ConfigFileManager;
26 use Friendica\Core\Config\ValueObject\Cache;
27
28 /**
29  * Interface for accessing system-wide configurations
30  */
31 interface IManageConfigValues
32 {
33         /**
34          * Reloads all configuration values (from filesystem and environment variables)
35          *
36          * All configuration values of the system are stored in the cache.
37          *
38          * @return void
39          *
40          * @throws ConfigPersistenceException In case the persistence layer throws errors
41          */
42         public function reload();
43
44         /**
45          * Get a particular user's config variable given the category name
46          * ($cat) and a $key.
47          *
48          * Get a particular config value from the given category ($cat)
49          *
50          * @param string  $cat        The category of the configuration value
51          * @param string  $key           The configuration key to query
52          * @param mixed   $default_value Deprecated, use `Config->get($cat, $key, null, $refresh) ?? $default_value` instead
53          *
54          * @return mixed Stored value or null if it does not exist
55          *
56          * @throws ConfigPersistenceException In case the persistence layer throws errors
57          *
58          */
59         public function get(string $cat, string $key, $default_value = null);
60
61         /**
62          * Load all configuration values from a given cache and saves it back in the configuration node store
63          * @see ConfigFileManager::CONFIG_DATA_FILE
64          *
65          * All configuration values of the system are stored in the cache.
66          *
67          * @param Cache $cache a new cache
68          *
69          * @return void
70          *
71          * @throws ConfigPersistenceException In case the persistence layer throws errors
72          */
73         public function load(Cache $cache);
74
75         /**
76          * Sets a configuration value for system config
77          *
78          * Stores a config value ($value) in the category ($cat) under the key ($key)
79          *
80          * Note: Please do not store booleans - convert to 0/1 integer values!
81          *
82          * @param string $cat The category of the configuration value
83          * @param string $key    The configuration key to set
84          * @param mixed  $value  The value to store
85          *
86          * @return bool Operation success
87          *
88          * @throws ConfigPersistenceException In case the persistence layer throws errors
89          */
90         public function set(string $cat, string $key, $value): bool;
91
92         /**
93          * Creates a transactional config value store, which is used to set a bunch of values at once
94          *
95          * It relies on the current instance, so after save(), the values of this config class will get altered at once too.
96          *
97          * @return ISetConfigValuesTransactionally
98          */
99         public function beginTransaction(): ISetConfigValuesTransactionally;
100
101         /**
102          * Deletes the given key from the system configuration.
103          *
104          * Removes the configured value from the stored cache in the cache and removes it from the database.
105          *
106          * @param string $cat The category of the configuration value
107          * @param string $key    The configuration key to delete
108          *
109          * @return bool
110          *
111          * @throws ConfigPersistenceException In case the persistence layer throws errors
112          *
113          */
114         public function delete(string $cat, string $key): bool;
115
116         /**
117          * Returns the Config Cache
118          *
119          * @return Cache
120          */
121         public function getCache(): Cache;
122 }