|
12 | 12 | use InvalidArgumentException; |
13 | 13 | use JsonException; |
14 | 14 | use NCU\Config\Lexicon\ConfigLexiconEntry; |
| 15 | +use NCU\Config\Lexicon\ConfigLexiconPreset; |
15 | 16 | use NCU\Config\Lexicon\ConfigLexiconStrictness; |
16 | 17 | use NCU\Config\Lexicon\IConfigLexicon; |
17 | 18 | use OC\AppFramework\Bootstrap\Coordinator; |
@@ -64,12 +65,13 @@ class AppConfig implements IAppConfig { |
64 | 65 | /** @var array<string, array{entries: array<string, ConfigLexiconEntry>, aliases: array<string, string>, strictness: ConfigLexiconStrictness}> ['app_id' => ['strictness' => ConfigLexiconStrictness, 'entries' => ['config_key' => ConfigLexiconEntry[]]] */ |
65 | 66 | private array $configLexiconDetails = []; |
66 | 67 | private bool $ignoreLexiconAliases = false; |
67 | | - |
| 68 | + private ?ConfigLexiconPreset $configLexiconPreset = null; |
68 | 69 | /** @var ?array<string, string> */ |
69 | 70 | private ?array $appVersionsCache = null; |
70 | 71 |
|
71 | 72 | public function __construct( |
72 | 73 | protected IDBConnection $connection, |
| 74 | + protected IConfig $config, |
73 | 75 | protected LoggerInterface $logger, |
74 | 76 | protected ICrypto $crypto, |
75 | 77 | ) { |
@@ -1147,6 +1149,7 @@ public function deleteApp(string $app): void { |
1147 | 1149 | public function clearCache(bool $reload = false): void { |
1148 | 1150 | $this->lazyLoaded = $this->fastLoaded = false; |
1149 | 1151 | $this->lazyCache = $this->fastCache = $this->valueTypes = []; |
| 1152 | + $this->configLexiconPreset = null; |
1150 | 1153 |
|
1151 | 1154 | if (!$reload) { |
1152 | 1155 | return; |
@@ -1629,7 +1632,7 @@ private function matchAndApplyLexiconDefinition( |
1629 | 1632 | } |
1630 | 1633 |
|
1631 | 1634 | $lazy = $configValue->isLazy(); |
1632 | | - $default = $configValue->getDefault() ?? $default; // default from Lexicon got priority |
| 1635 | + $default = $configValue->getDefault($this->getLexiconPreset()) ?? $default; // default from Lexicon got priority |
1633 | 1636 | if ($configValue->isFlagged(self::FLAG_SENSITIVE)) { |
1634 | 1637 | $type |= self::VALUE_SENSITIVE; |
1635 | 1638 | } |
@@ -1715,6 +1718,14 @@ public function ignoreLexiconAliases(bool $ignore): void { |
1715 | 1718 | $this->ignoreLexiconAliases = $ignore; |
1716 | 1719 | } |
1717 | 1720 |
|
| 1721 | + private function getLexiconPreset(): ConfigLexiconPreset { |
| 1722 | + if ($this->configLexiconPreset === null) { |
| 1723 | + $this->configLexiconPreset = ConfigLexiconPreset::tryFrom($this->config->getSystemValueInt(ConfigManager::PRESET_CONFIGKEY, 0)) ?? ConfigLexiconPreset::NONE; |
| 1724 | + } |
| 1725 | + |
| 1726 | + return $this->configLexiconPreset; |
| 1727 | + } |
| 1728 | + |
1718 | 1729 | /** |
1719 | 1730 | * Returns the installed versions of all apps |
1720 | 1731 | * |
|
0 commit comments