mirror of
https://github.com/friendica/friendica
synced 2025-04-27 07:10:12 +00:00
Disable setting fields in case we use environment variables
This commit is contained in:
parent
f61fd93db0
commit
76f3b07033
11 changed files with 65 additions and 19 deletions
|
@ -58,6 +58,16 @@ interface IManageConfigValues
|
|||
*/
|
||||
public function get(string $cat, string $key = null, $default_value = null);
|
||||
|
||||
/**
|
||||
* Returns true, if the current config cannot be changed
|
||||
*
|
||||
* @param string $cat The category of the configuration value
|
||||
* @param string $key The configuration key to query
|
||||
*
|
||||
* @return bool true, if set is disabled
|
||||
*/
|
||||
public function isSetDisabled(string $cat, string $key): bool;
|
||||
|
||||
/**
|
||||
* Sets a configuration value for system config
|
||||
*
|
||||
|
|
|
@ -80,6 +80,12 @@ class DatabaseConfig implements IManageConfigValues
|
|||
return $this->cache->get($cat, $key) ?? $default_value;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public function isSetDisabled(string $cat, string $key): bool
|
||||
{
|
||||
return $this->cache->getSource($cat, $key) >= Cache::SOURCE_ENV;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public function set(string $cat, string $key, $value): bool
|
||||
{
|
||||
|
|
|
@ -68,6 +68,12 @@ class ReadOnlyFileConfig implements IManageConfigValues
|
|||
return $this->configCache->get($cat, $key) ?? $default_value;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public function isSetDisabled(string $cat, string $key): bool
|
||||
{
|
||||
return $this->configCache->getSource($cat, $key) >= Cache::SOURCE_ENV;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public function set(string $cat, string $key, $value): bool
|
||||
{
|
||||
|
|
|
@ -31,6 +31,15 @@ use ParagonIE\HiddenString\HiddenString;
|
|||
*/
|
||||
class Cache
|
||||
{
|
||||
/** @var int[] A list of valid config source */
|
||||
const VALID_SOURCES = [
|
||||
self::SOURCE_STATIC,
|
||||
self::SOURCE_FILE,
|
||||
self::SOURCE_DATA,
|
||||
self::SOURCE_ENV,
|
||||
self::SOURCE_FIX,
|
||||
];
|
||||
|
||||
/** @var int Indicates that the cache entry is a default value - Lowest Priority */
|
||||
const SOURCE_STATIC = 0;
|
||||
/** @var int Indicates that the cache entry is set by file - Low Priority */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue