aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/AppConfig.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private/AppConfig.php')
-rw-r--r--lib/private/AppConfig.php26
1 files changed, 8 insertions, 18 deletions
diff --git a/lib/private/AppConfig.php b/lib/private/AppConfig.php
index 2280ac1a79f..cef612536d6 100644
--- a/lib/private/AppConfig.php
+++ b/lib/private/AppConfig.php
@@ -13,9 +13,9 @@ use InvalidArgumentException;
use JsonException;
use OC\AppFramework\Bootstrap\Coordinator;
use OC\Config\ConfigManager;
+use OC\Config\PresetManager;
use OCP\Config\Lexicon\Entry;
use OCP\Config\Lexicon\ILexicon;
-use OCP\Config\Lexicon\Preset;
use OCP\Config\Lexicon\Strictness;
use OCP\Config\ValueType;
use OCP\DB\Exception as DBException;
@@ -27,7 +27,6 @@ use OCP\IAppConfig;
use OCP\IConfig;
use OCP\IDBConnection;
use OCP\Security\ICrypto;
-use OCP\Server;
use Psr\Log\LoggerInterface;
/**
@@ -66,13 +65,14 @@ class AppConfig implements IAppConfig {
/** @var array<string, array{entries: array<string, Entry>, aliases: array<string, string>, strictness: Strictness}> ['app_id' => ['strictness' => ConfigLexiconStrictness, 'entries' => ['config_key' => ConfigLexiconEntry[]]] */
private array $configLexiconDetails = [];
private bool $ignoreLexiconAliases = false;
- private ?Preset $configLexiconPreset = null;
/** @var ?array<string, string> */
private ?array $appVersionsCache = null;
public function __construct(
protected IDBConnection $connection,
protected IConfig $config,
+ private readonly ConfigManager $configManager,
+ private readonly PresetManager $presetManager,
protected LoggerInterface $logger,
protected ICrypto $crypto,
) {
@@ -520,8 +520,7 @@ class AppConfig implements IAppConfig {
// interested to check options in case a modification of the value is needed
// ie inverting value from previous key when using lexicon option RENAME_INVERT_BOOLEAN
if ($origKey !== $key && $type === self::VALUE_BOOL) {
- $configManager = Server::get(ConfigManager::class);
- $value = ($configManager->convertToBool($value, $this->getLexiconEntry($app, $key))) ? '1' : '0';
+ $value = ($this->configManager->convertToBool($value, $this->getLexiconEntry($app, $key))) ? '1' : '0';
}
return $value;
@@ -1108,7 +1107,7 @@ class AppConfig implements IAppConfig {
$this->assertParams($app, $key);
try {
$details = $this->getDetails($app, $key);
- } catch (AppConfigUnknownKeyException $e) {
+ } catch (AppConfigUnknownKeyException) {
$details = [
'app' => $app,
'key' => $key
@@ -1129,13 +1128,13 @@ class AppConfig implements IAppConfig {
'valueType' => $lexiconEntry->getValueType(),
'valueTypeName' => $lexiconEntry->getValueType()->name,
'sensitive' => $lexiconEntry->isFlagged(self::FLAG_SENSITIVE),
- 'default' => $lexiconEntry->getDefault($this->getLexiconPreset()),
+ 'default' => $lexiconEntry->getDefault($this->presetManager->getLexiconPreset()),
'definition' => $lexiconEntry->getDefinition(),
'note' => $lexiconEntry->getNote(),
]);
}
- return array_filter($details);
+ return array_filter($details, static fn ($v): bool => ($v !== null));
}
/**
@@ -1228,7 +1227,6 @@ class AppConfig implements IAppConfig {
public function clearCache(bool $reload = false): void {
$this->lazyLoaded = $this->fastLoaded = false;
$this->lazyCache = $this->fastCache = $this->valueTypes = $this->configLexiconDetails = [];
- $this->configLexiconPreset = null;
if (!$reload) {
return;
@@ -1714,7 +1712,7 @@ class AppConfig implements IAppConfig {
$lazy = $lexiconEntry->isLazy();
// only look for default if needed, default from Lexicon got priority
if ($default !== null) {
- $default = $lexiconEntry->getDefault($this->getLexiconPreset()) ?? $default;
+ $default = $lexiconEntry->getDefault($this->presetManager->getLexiconPreset()) ?? $default;
}
if ($lexiconEntry->isFlagged(self::FLAG_SENSITIVE)) {
@@ -1802,14 +1800,6 @@ class AppConfig implements IAppConfig {
$this->ignoreLexiconAliases = $ignore;
}
- private function getLexiconPreset(): Preset {
- if ($this->configLexiconPreset === null) {
- $this->configLexiconPreset = Preset::tryFrom($this->config->getSystemValueInt(ConfigManager::PRESET_CONFIGKEY, 0)) ?? Preset::NONE;
- }
-
- return $this->configLexiconPreset;
- }
-
/**
* Returns the installed versions of all apps
*