3 * @copyright Copyright (C) 2010-2022, 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\PConfig\Capability;
24 use Friendica\Core\PConfig\ValueObject;
27 * Interface for accessing user specific configurations
29 interface IManagePersonalConfigValues
32 * Loads all configuration values of a user's config family into a cached storage.
34 * All configuration values of the given user are stored with the $uid in the cache
36 * @param int $uid The user_id
37 * @param string $cat The category of the configuration value
39 * @return array The loaded config array
41 public function load(int $uid, string $cat = 'config'): array;
44 * Get a particular user's config variable given the category name
47 * Get a particular user's config value from the given category ($cat)
48 * and the $key with the $uid from a cached storage either from the database
49 * or from the configCache
51 * @param int $uid The user_id
52 * @param string $cat The category of the configuration value
53 * @param string $key The configuration key to query
54 * @param mixed $default_value Deprecated, use `PConfig->get($uid, $cat, $key, null, $refresh) ?? $default_value` instead
55 * @param boolean $refresh optional, If true the config is loaded from the db and not from the cache (default: false)
57 * @return mixed Stored value or null if it does not exist
60 public function get(int $uid, string $cat, string $key, $default_value = null, bool $refresh = false);
63 * Sets a configuration value for a user
65 * Stores a config value ($value) in the category ($family) under the key ($key)
66 * for the user_id $uid.
68 * @note Please do not store booleans - convert to 0/1 integer values!
70 * @param int $uid The user_id
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
75 * @return bool Operation success
77 public function set(int $uid, string $cat, string $key, $value): bool;
80 * Deletes the given key from the users configuration.
82 * Removes the configured value from the stored cache and removes it from the database with the given $uid.
84 * @param int $uid The user_id
85 * @param string $cat The category of the configuration value
86 * @param string $key The configuration key to delete
90 public function delete(int $uid, string $cat, string $key): bool;
94 * Returns the Config Cache
96 * @return ValueObject\Cache
98 public function getCache(): ValueObject\Cache;