2019-12-19 20:11:07 +01:00
|
|
|
<?php
|
2020-02-09 15:45:36 +01:00
|
|
|
/**
|
2023-01-01 15:36:24 +01:00
|
|
|
* @copyright Copyright (C) 2010-2023, the Friendica project
|
2020-02-09 15:45:36 +01:00
|
|
|
*
|
|
|
|
* @license GNU AGPL version 3 or any later version
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as
|
|
|
|
* published by the Free Software Foundation, either version 3 of the
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
2019-12-19 20:11:07 +01:00
|
|
|
|
2021-10-26 21:44:29 +02:00
|
|
|
namespace Friendica\Core\Config\Capability;
|
2019-12-19 20:11:07 +01:00
|
|
|
|
2021-10-26 21:44:29 +02:00
|
|
|
use Friendica\Core\Config\Exception\ConfigPersistenceException;
|
|
|
|
use Friendica\Core\Config\ValueObject\Cache;
|
2021-10-23 11:29:16 +02:00
|
|
|
|
2019-12-19 20:11:07 +01:00
|
|
|
/**
|
2021-10-26 21:44:29 +02:00
|
|
|
* Interface for accessing system-wide configurations
|
2019-12-19 20:11:07 +01:00
|
|
|
*/
|
2021-10-26 21:44:29 +02:00
|
|
|
interface IManageConfigValues
|
2019-12-19 20:11:07 +01:00
|
|
|
{
|
|
|
|
/**
|
2022-12-28 02:07:38 +01:00
|
|
|
* Reloads all configuration values (from filesystem and environment variables)
|
2019-12-19 20:11:07 +01:00
|
|
|
*
|
2021-10-26 21:44:29 +02:00
|
|
|
* All configuration values of the system are stored in the cache.
|
|
|
|
*
|
2019-12-19 20:11:07 +01:00
|
|
|
* @return void
|
2021-10-26 21:44:29 +02:00
|
|
|
*
|
|
|
|
* @throws ConfigPersistenceException In case the persistence layer throws errors
|
2019-12-19 20:11:07 +01:00
|
|
|
*/
|
2022-12-28 02:07:38 +01:00
|
|
|
public function reload();
|
2019-12-19 20:11:07 +01:00
|
|
|
|
|
|
|
/**
|
2020-01-19 07:05:23 +01:00
|
|
|
* Get a particular user's config variable given the category name
|
2019-12-19 20:11:07 +01:00
|
|
|
* ($cat) and a $key.
|
|
|
|
*
|
|
|
|
* Get a particular config value from the given category ($cat)
|
|
|
|
*
|
|
|
|
* @param string $cat The category of the configuration value
|
|
|
|
* @param string $key The configuration key to query
|
2022-11-03 01:38:23 +01:00
|
|
|
* @param mixed $default_value Deprecated, use `Config->get($cat, $key, null, $refresh) ?? $default_value` instead
|
2019-12-19 20:11:07 +01:00
|
|
|
*
|
|
|
|
* @return mixed Stored value or null if it does not exist
|
2021-10-26 21:44:29 +02:00
|
|
|
*
|
|
|
|
* @throws ConfigPersistenceException In case the persistence layer throws errors
|
|
|
|
*
|
2019-12-19 20:11:07 +01:00
|
|
|
*/
|
2022-12-28 02:07:38 +01:00
|
|
|
public function get(string $cat, string $key, $default_value = null);
|
2019-12-19 20:11:07 +01:00
|
|
|
|
|
|
|
/**
|
2020-01-19 07:05:23 +01:00
|
|
|
* Sets a configuration value for system config
|
2019-12-19 20:11:07 +01:00
|
|
|
*
|
|
|
|
* Stores a config value ($value) in the category ($cat) under the key ($key)
|
|
|
|
*
|
|
|
|
* Note: Please do not store booleans - convert to 0/1 integer values!
|
|
|
|
*
|
|
|
|
* @param string $cat The category of the configuration value
|
|
|
|
* @param string $key The configuration key to set
|
|
|
|
* @param mixed $value The value to store
|
2023-01-01 21:10:37 +01:00
|
|
|
* @param bool $autosave If true, implicit save the value
|
2019-12-19 20:11:07 +01:00
|
|
|
*
|
|
|
|
* @return bool Operation success
|
2021-10-26 21:44:29 +02:00
|
|
|
*
|
|
|
|
* @throws ConfigPersistenceException In case the persistence layer throws errors
|
2019-12-19 20:11:07 +01:00
|
|
|
*/
|
2023-01-01 21:10:37 +01:00
|
|
|
public function set(string $cat, string $key, $value, bool $autosave = true): bool;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Save back the overridden values of the config cache
|
2022-12-28 02:07:38 +01:00
|
|
|
*
|
|
|
|
* @throws ConfigPersistenceException In case the persistence layer throws errors
|
2023-01-01 21:10:37 +01:00
|
|
|
*/
|
|
|
|
public function save();
|
2019-12-19 20:11:07 +01:00
|
|
|
|
|
|
|
/**
|
2020-01-19 07:05:23 +01:00
|
|
|
* Deletes the given key from the system configuration.
|
2019-12-19 20:11:07 +01:00
|
|
|
*
|
2021-10-26 21:44:29 +02:00
|
|
|
* Removes the configured value from the stored cache in the cache and removes it from the database.
|
2019-12-19 20:11:07 +01:00
|
|
|
*
|
|
|
|
* @param string $cat The category of the configuration value
|
|
|
|
* @param string $key The configuration key to delete
|
2023-01-01 21:10:37 +01:00
|
|
|
* @param bool $autosave If true, implicit save the value
|
2019-12-19 20:11:07 +01:00
|
|
|
*
|
|
|
|
* @return bool
|
2021-10-26 21:44:29 +02:00
|
|
|
*
|
|
|
|
* @throws ConfigPersistenceException In case the persistence layer throws errors
|
|
|
|
*
|
2019-12-19 20:11:07 +01:00
|
|
|
*/
|
2023-01-01 21:10:37 +01:00
|
|
|
public function delete(string $cat, string $key, bool $autosave = true): bool;
|
2019-12-19 20:11:07 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the Config Cache
|
|
|
|
*
|
2020-01-19 22:23:44 +01:00
|
|
|
* @return Cache
|
2019-12-19 20:11:07 +01:00
|
|
|
*/
|
2021-10-26 21:44:29 +02:00
|
|
|
public function getCache(): Cache;
|
2019-12-19 20:11:07 +01:00
|
|
|
}
|