1313use JsonException ;
1414use OC \AppFramework \Bootstrap \Coordinator ;
1515use OC \Config \ConfigManager ;
16+ use OC \Config \PresetManager ;
1617use OCP \Config \Lexicon \Entry ;
1718use OCP \Config \Lexicon \ILexicon ;
18- use OCP \Config \Lexicon \Preset ;
1919use OCP \Config \Lexicon \Strictness ;
2020use OCP \Config \ValueType ;
2121use OCP \DB \Exception as DBException ;
2727use OCP \IConfig ;
2828use OCP \IDBConnection ;
2929use OCP \Security \ICrypto ;
30- use OCP \Server ;
3130use Psr \Log \LoggerInterface ;
3231
3332/**
@@ -66,13 +65,14 @@ class AppConfig implements IAppConfig {
6665 /** @var array<string, array{entries: array<string, Entry>, aliases: array<string, string>, strictness: Strictness}> ['app_id' => ['strictness' => ConfigLexiconStrictness, 'entries' => ['config_key' => ConfigLexiconEntry[]]] */
6766 private array $ configLexiconDetails = [];
6867 private bool $ ignoreLexiconAliases = false ;
69- private ?Preset $ configLexiconPreset = null ;
7068 /** @var ?array<string, string> */
7169 private ?array $ appVersionsCache = null ;
7270
7371 public function __construct (
7472 protected IDBConnection $ connection ,
7573 protected IConfig $ config ,
74+ private readonly ConfigManager $ configManager ,
75+ private readonly PresetManager $ presetManager ,
7676 protected LoggerInterface $ logger ,
7777 protected ICrypto $ crypto ,
7878 ) {
@@ -520,8 +520,7 @@ private function getTypedValue(
520520 // interested to check options in case a modification of the value is needed
521521 // ie inverting value from previous key when using lexicon option RENAME_INVERT_BOOLEAN
522522 if ($ origKey !== $ key && $ type === self ::VALUE_BOOL ) {
523- $ configManager = Server::get (ConfigManager::class);
524- $ value = ($ configManager ->convertToBool ($ value , $ this ->getLexiconEntry ($ app , $ key ))) ? '1 ' : '0 ' ;
523+ $ value = ($ this ->configManager ->convertToBool ($ value , $ this ->getLexiconEntry ($ app , $ key ))) ? '1 ' : '0 ' ;
525524 }
526525
527526 return $ value ;
@@ -1108,7 +1107,7 @@ public function getKeyDetails(string $app, string $key): array {
11081107 $ this ->assertParams ($ app , $ key );
11091108 try {
11101109 $ details = $ this ->getDetails ($ app , $ key );
1111- } catch (AppConfigUnknownKeyException $ e ) {
1110+ } catch (AppConfigUnknownKeyException ) {
11121111 $ details = [
11131112 'app ' => $ app ,
11141113 'key ' => $ key
@@ -1129,13 +1128,13 @@ public function getKeyDetails(string $app, string $key): array {
11291128 'valueType ' => $ lexiconEntry ->getValueType (),
11301129 'valueTypeName ' => $ lexiconEntry ->getValueType ()->name ,
11311130 'sensitive ' => $ lexiconEntry ->isFlagged (self ::FLAG_SENSITIVE ),
1132- 'default ' => $ lexiconEntry ->getDefault ($ this ->getLexiconPreset ()),
1131+ 'default ' => $ lexiconEntry ->getDefault ($ this ->presetManager -> getLexiconPreset ()),
11331132 'definition ' => $ lexiconEntry ->getDefinition (),
11341133 'note ' => $ lexiconEntry ->getNote (),
11351134 ]);
11361135 }
11371136
1138- return array_filter ($ details );
1137+ return array_filter ($ details, static fn ( $ v ): bool => ( $ v !== null ) );
11391138 }
11401139
11411140 /**
@@ -1228,7 +1227,6 @@ public function deleteApp(string $app): void {
12281227 public function clearCache (bool $ reload = false ): void {
12291228 $ this ->lazyLoaded = $ this ->fastLoaded = false ;
12301229 $ this ->lazyCache = $ this ->fastCache = $ this ->valueTypes = $ this ->configLexiconDetails = [];
1231- $ this ->configLexiconPreset = null ;
12321230
12331231 if (!$ reload ) {
12341232 return ;
@@ -1714,7 +1712,7 @@ private function matchAndApplyLexiconDefinition(
17141712 $ lazy = $ lexiconEntry ->isLazy ();
17151713 // only look for default if needed, default from Lexicon got priority
17161714 if ($ default !== null ) {
1717- $ default = $ lexiconEntry ->getDefault ($ this ->getLexiconPreset ()) ?? $ default ;
1715+ $ default = $ lexiconEntry ->getDefault ($ this ->presetManager -> getLexiconPreset ()) ?? $ default ;
17181716 }
17191717
17201718 if ($ lexiconEntry ->isFlagged (self ::FLAG_SENSITIVE )) {
@@ -1802,14 +1800,6 @@ public function ignoreLexiconAliases(bool $ignore): void {
18021800 $ this ->ignoreLexiconAliases = $ ignore ;
18031801 }
18041802
1805- private function getLexiconPreset (): Preset {
1806- if ($ this ->configLexiconPreset === null ) {
1807- $ this ->configLexiconPreset = Preset::tryFrom ($ this ->config ->getSystemValueInt (ConfigManager::PRESET_CONFIGKEY , 0 )) ?? Preset::NONE ;
1808- }
1809-
1810- return $ this ->configLexiconPreset ;
1811- }
1812-
18131803 /**
18141804 * Returns the installed versions of all apps
18151805 *
0 commit comments