]> git.mxchange.org Git - friendica.git/blob - src/Core/Config/Capability/ISetConfigValuesTransactional.php
9c58427a0433a02041cc5d85d884a77d3925e0ce
[friendica.git] / src / Core / Config / Capability / ISetConfigValuesTransactional.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
26 /**
27  * Interface for transactional saving of config values
28  * It buffers every set/delete until "save()" is called
29  */
30 interface ISetConfigValuesTransactional
31 {
32         /**
33          * Get a particular user's config variable given the category name
34          * ($cat) and a $key.
35          *
36          * Get a particular config value from the given category ($cat)
37          *
38          * @param string  $cat        The category of the configuration value
39          * @param string  $key           The configuration key to query
40          *
41          * @return mixed Stored value or null if it does not exist
42          *
43          * @throws ConfigPersistenceException In case the persistence layer throws errors
44          *
45          */
46         public function get(string $cat, string $key);
47
48         /**
49          * Sets a configuration value for system config
50          *
51          * Stores a config value ($value) in the category ($cat) under the key ($key)
52          *
53          * Note: Please do not store booleans - convert to 0/1 integer values!
54          *
55          * @param string $cat The category of the configuration value
56          * @param string $key    The configuration key to set
57          * @param mixed  $value  The value to store
58          *
59          * @return static the current instance
60          *
61          * @throws ConfigPersistenceException In case the persistence layer throws errors
62          */
63         public function set(string $cat, string $key, $value): self;
64
65         /**
66          * Deletes the given key from the system configuration.
67          *
68          * @param string $cat The category of the configuration value
69          * @param string $key The configuration key to delete
70          *
71          * @return static the current instance
72          *
73          * @throws ConfigPersistenceException In case the persistence layer throws errors
74          *
75          */
76         public function delete(string $cat, string $key): self;
77
78         /**
79          * Saves the node specific config values
80          *
81          * @throws ConfigPersistenceException In case the persistence layer throws errors
82          */
83         public function save(): void;
84 }