diff options
Diffstat (limited to 'lib/private/Config')
-rw-r--r-- | lib/private/Config/ConfigManager.php | 23 | ||||
-rw-r--r-- | lib/private/Config/Lexicon/CoreConfigLexicon.php | 22 | ||||
-rw-r--r-- | lib/private/Config/UserConfig.php | 46 |
3 files changed, 47 insertions, 44 deletions
diff --git a/lib/private/Config/ConfigManager.php b/lib/private/Config/ConfigManager.php index 67466617941..ed516abdcbf 100644 --- a/lib/private/Config/ConfigManager.php +++ b/lib/private/Config/ConfigManager.php @@ -9,13 +9,13 @@ declare(strict_types=1); namespace OC\Config; use JsonException; -use NCU\Config\Exceptions\TypeConflictException; -use NCU\Config\IUserConfig; -use NCU\Config\Lexicon\ConfigLexiconEntry; -use NCU\Config\Lexicon\Preset; -use NCU\Config\ValueType; use OC\AppConfig; use OCP\App\IAppManager; +use OCP\Config\Exceptions\TypeConflictException; +use OCP\Config\IUserConfig; +use OCP\Config\Lexicon\Entry; +use OCP\Config\Lexicon\Preset; +use OCP\Config\ValueType; use OCP\IAppConfig; use OCP\IConfig; use OCP\Server; @@ -50,10 +50,11 @@ class ConfigManager { * * This method should be mainly called during a new upgrade or when a new app is enabled. * - * @see ConfigLexiconEntry + * @param string|null $appId when set to NULL the method will be executed for all enabled apps of the instance + * * @internal * @since 32.0.0 - * @param string|null $appId when set to NULL the method will be executed for all enabled apps of the instance + * @see Entry */ public function migrateConfigLexiconKeys(?string $appId = null): void { if ($appId === null) { @@ -166,7 +167,7 @@ class ConfigManager { * * @throws TypeConflictException if previous value does not fit the expected type */ - private function migrateAppConfigValue(string $appId, ConfigLexiconEntry $entry): void { + private function migrateAppConfigValue(string $appId, Entry $entry): void { $value = $this->appConfig->getValueMixed($appId, $entry->getRename(), lazy: null); switch ($entry->getValueType()) { case ValueType::STRING: @@ -196,7 +197,7 @@ class ConfigManager { * * @throws TypeConflictException if previous value does not fit the expected type */ - private function migrateUserConfigValue(string $userId, string $appId, ConfigLexiconEntry $entry): void { + private function migrateUserConfigValue(string $userId, string $appId, Entry $entry): void { $value = $this->userConfig->getValueMixed($userId, $appId, $entry->getRename(), lazy: null); switch ($entry->getValueType()) { case ValueType::STRING: @@ -237,7 +238,7 @@ class ConfigManager { return (float)$value; } - public function convertToBool(string $value, ?ConfigLexiconEntry $entry = null): bool { + public function convertToBool(string $value, ?Entry $entry = null): bool { if (in_array(strtolower($value), ['true', '1', 'on', 'yes'])) { $valueBool = true; } elseif (in_array(strtolower($value), ['false', '0', 'off', 'no'])) { @@ -245,7 +246,7 @@ class ConfigManager { } else { throw new TypeConflictException('Value cannot be converted to boolean'); } - if ($entry?->hasOption(ConfigLexiconEntry::RENAME_INVERT_BOOLEAN) === true) { + if ($entry?->hasOption(Entry::RENAME_INVERT_BOOLEAN) === true) { $valueBool = !$valueBool; } diff --git a/lib/private/Config/Lexicon/CoreConfigLexicon.php b/lib/private/Config/Lexicon/CoreConfigLexicon.php index 34a0b883c54..de84a58131c 100644 --- a/lib/private/Config/Lexicon/CoreConfigLexicon.php +++ b/lib/private/Config/Lexicon/CoreConfigLexicon.php @@ -8,36 +8,36 @@ declare(strict_types=1); namespace OC\Config\Lexicon; -use NCU\Config\Lexicon\ConfigLexiconEntry; -use NCU\Config\Lexicon\ConfigLexiconStrictness; -use NCU\Config\Lexicon\IConfigLexicon; -use NCU\Config\ValueType; +use OCP\Config\Lexicon\Entry; +use OCP\Config\Lexicon\ILexicon; +use OCP\Config\Lexicon\Strictness; +use OCP\Config\ValueType; /** * ConfigLexicon for 'core' app/user configs */ -class CoreConfigLexicon implements IConfigLexicon { - public function getStrictness(): ConfigLexiconStrictness { - return ConfigLexiconStrictness::IGNORE; +class CoreConfigLexicon implements ILexicon { + public function getStrictness(): Strictness { + return Strictness::IGNORE; } /** * @inheritDoc - * @return ConfigLexiconEntry[] + * @return Entry[] */ public function getAppConfigs(): array { return [ - new ConfigLexiconEntry('lastcron', ValueType::INT, 0, 'timestamp of last cron execution'), + new Entry('lastcron', ValueType::INT, 0, 'timestamp of last cron execution'), ]; } /** * @inheritDoc - * @return ConfigLexiconEntry[] + * @return Entry[] */ public function getUserConfigs(): array { return [ - new ConfigLexiconEntry('lang', ValueType::STRING, null, 'language'), + new Entry('lang', ValueType::STRING, null, 'language'), ]; } } diff --git a/lib/private/Config/UserConfig.php b/lib/private/Config/UserConfig.php index fb0bf954f57..04ba0e29db0 100644 --- a/lib/private/Config/UserConfig.php +++ b/lib/private/Config/UserConfig.php @@ -11,15 +11,16 @@ namespace OC\Config; use Generator; use InvalidArgumentException; use JsonException; -use NCU\Config\Exceptions\IncorrectTypeException; -use NCU\Config\Exceptions\TypeConflictException; -use NCU\Config\Exceptions\UnknownKeyException; -use NCU\Config\IUserConfig; -use NCU\Config\Lexicon\ConfigLexiconEntry; -use NCU\Config\Lexicon\ConfigLexiconStrictness; -use NCU\Config\Lexicon\Preset; -use NCU\Config\ValueType; use OC\AppFramework\Bootstrap\Coordinator; +use OCP\Config\Exceptions\IncorrectTypeException; +use OCP\Config\Exceptions\TypeConflictException; +use OCP\Config\Exceptions\UnknownKeyException; +use OCP\Config\IUserConfig; +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; use OCP\DB\IResult; use OCP\DB\QueryBuilder\IQueryBuilder; @@ -64,7 +65,7 @@ class UserConfig implements IUserConfig { private array $fastLoaded = []; /** @var array<string, boolean> ['user_id' => bool] */ private array $lazyLoaded = []; - /** @var array<string, array{entries: array<string, ConfigLexiconEntry>, aliases: array<string, string>, strictness: ConfigLexiconStrictness}> ['app_id' => ['strictness' => ConfigLexiconStrictness, 'entries' => ['config_key' => ConfigLexiconEntry[]]] */ + /** @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; @@ -1913,7 +1914,7 @@ class UserConfig implements IUserConfig { return true; } - /** @var ConfigLexiconEntry $configValue */ + /** @var Entry $configValue */ $configValue = $configDetails['entries'][$key]; if ($type === ValueType::MIXED) { // we overwrite if value was requested as mixed @@ -1954,7 +1955,7 @@ class UserConfig implements IUserConfig { * * The entry is converted to string to fit the expected type when managing default value */ - private function getSystemDefault(string $appId, ConfigLexiconEntry $configValue): ?string { + private function getSystemDefault(string $appId, Entry $configValue): ?string { $default = $this->config->getSystemValue('lexicon.default.userconfig', [])[$appId][$configValue->getKey()] ?? null; if ($default === null) { // no system default, using default default. @@ -1967,28 +1968,28 @@ class UserConfig implements IUserConfig { /** * manage ConfigLexicon behavior based on strictness set in IConfigLexicon * - * @see IConfigLexicon::getStrictness() - * @param ConfigLexiconStrictness|null $strictness + * @param Strictness|null $strictness * @param string $line * * @return bool TRUE if conflict can be fully ignored * @throws UnknownKeyException + *@see ILexicon::getStrictness() */ - private function applyLexiconStrictness(?ConfigLexiconStrictness $strictness, string $line = ''): bool { + private function applyLexiconStrictness(?Strictness $strictness, string $line = ''): bool { if ($strictness === null) { return true; } switch ($strictness) { - case ConfigLexiconStrictness::IGNORE: + case Strictness::IGNORE: return true; - case ConfigLexiconStrictness::NOTICE: + case Strictness::NOTICE: $this->logger->notice($line); return true; - case ConfigLexiconStrictness::WARNING: + case Strictness::WARNING: $this->logger->warning($line); return false; - case ConfigLexiconStrictness::EXCEPTION: + case Strictness::EXCEPTION: throw new UnknownKeyException($line); } @@ -1999,9 +2000,10 @@ class UserConfig implements IUserConfig { * extract details from registered $appId's config lexicon * * @param string $appId - * @internal * - * @return array{entries: array<string, ConfigLexiconEntry>, aliases: array<string, string>, strictness: ConfigLexiconStrictness} + * @return array{entries: array<string, Entry>, aliases: array<string, string>, strictness: Strictness} + *@internal + * */ public function getConfigDetailsFromLexicon(string $appId): array { if (!array_key_exists($appId, $this->configLexiconDetails)) { @@ -2018,14 +2020,14 @@ class UserConfig implements IUserConfig { $this->configLexiconDetails[$appId] = [ 'entries' => $entries, 'aliases' => $aliases, - 'strictness' => $configLexicon?->getStrictness() ?? ConfigLexiconStrictness::IGNORE + 'strictness' => $configLexicon?->getStrictness() ?? Strictness::IGNORE ]; } return $this->configLexiconDetails[$appId]; } - private function getLexiconEntry(string $appId, string $key): ?ConfigLexiconEntry { + private function getLexiconEntry(string $appId, string $key): ?Entry { return $this->getConfigDetailsFromLexicon($appId)['entries'][$key] ?? null; } |