diff --git a/NCU/Config/Lexicon/ConfigLexiconEntry.php b/NCU/Config/Lexicon/ConfigLexiconEntry.php new file mode 100644 index 0000000..e6c6579 --- /dev/null +++ b/NCU/Config/Lexicon/ConfigLexiconEntry.php @@ -0,0 +1,189 @@ +default = match ($type) { + ValueType::MIXED => (string)$default, + ValueType::STRING => $this->convertFromString((string)$default), + ValueType::INT => $this->convertFromInt((int)$default), + ValueType::FLOAT => $this->convertFromFloat((float)$default), + ValueType::BOOL => $this->convertFromBool((bool)$default), + ValueType::ARRAY => $this->convertFromArray((array)$default) + }; + } + + /** @psalm-suppress UndefinedClass */ + if (\OC::$CLI) { // only store definition if ran from CLI + $this->definition = $definition; + } + } + + /** + * @inheritDoc + * + * @return string config key + * @experimental 31.0.0 + */ + public function getKey(): string { + return $this->key; + } + + /** + * @inheritDoc + * + * @return ValueType + * @experimental 31.0.0 + */ + public function getValueType(): ValueType { + return $this->type; + } + + /** + * @param string $default + * @return string + * @experimental 31.0.0 + */ + private function convertFromString(string $default): string { + return $default; + } + + /** + * @param int $default + * @return string + * @experimental 31.0.0 + */ + private function convertFromInt(int $default): string { + return (string)$default; + } + + /** + * @param float $default + * @return string + * @experimental 31.0.0 + */ + private function convertFromFloat(float $default): string { + return (string)$default; + } + + /** + * @param bool $default + * @return string + * @experimental 31.0.0 + */ + private function convertFromBool(bool $default): string { + return ($default) ? '1' : '0'; + } + + /** + * @param array $default + * @return string + * @experimental 31.0.0 + */ + private function convertFromArray(array $default): string { + return json_encode($default); + } + + /** + * @inheritDoc + * + * @return string|null NULL if no default is set + * @experimental 31.0.0 + */ + public function getDefault(): ?string { + return $this->default; + } + + /** + * @inheritDoc + * + * @return string + * @experimental 31.0.0 + */ + public function getDefinition(): string { + return $this->definition; + } + + /** + * @inheritDoc + * + * @see IAppConfig for details on lazy config values + * @return bool TRUE if config value is lazy + * @experimental 31.0.0 + */ + public function isLazy(): bool { + return $this->lazy; + } + + /** + * @inheritDoc + * + * @see IAppConfig for details on sensitive config values + * @return int bitflag about the config value + * @experimental 31.0.0 + */ + public function getFlags(): int { + return $this->flags; + } + + /** + * @param int $flag + * + * @return bool TRUE is config value bitflag contains $flag + * @experimental 31.0.0 + */ + public function isFlagged(int $flag): bool { + return (($flag & $this->getFlags()) === $flag); + } + + /** + * @inheritDoc + * + * @return bool TRUE if config si deprecated + * @experimental 31.0.0 + */ + public function isDeprecated(): bool { + return $this->deprecated; + } +} diff --git a/NCU/Config/Lexicon/ConfigLexiconStrictness.php b/NCU/Config/Lexicon/ConfigLexiconStrictness.php new file mode 100644 index 0000000..a649067 --- /dev/null +++ b/NCU/Config/Lexicon/ConfigLexiconStrictness.php @@ -0,0 +1,30 @@ +value); } } + + /** + * get corresponding AppConfig flag value + * + * @return int + * @throws IncorrectTypeException + * + * @experimental 31.0.0 + */ + public function toAppConfigFlag(): int { + try { + return match ($this) { + self::MIXED => IAppConfig::VALUE_MIXED, + self::STRING => IAppConfig::VALUE_STRING, + self::INT => IAppConfig::VALUE_INT, + self::FLOAT => IAppConfig::VALUE_FLOAT, + self::BOOL => IAppConfig::VALUE_BOOL, + self::ARRAY => IAppConfig::VALUE_ARRAY, + }; + } catch (UnhandledMatchError) { + throw new IncorrectTypeException('unknown type definition ' . $this->value); + } + } + } diff --git a/OCP/AppFramework/Bootstrap/IRegistrationContext.php b/OCP/AppFramework/Bootstrap/IRegistrationContext.php index b9e5413..8a18ec8 100644 --- a/OCP/AppFramework/Bootstrap/IRegistrationContext.php +++ b/OCP/AppFramework/Bootstrap/IRegistrationContext.php @@ -423,4 +423,15 @@ public function registerTaskProcessingTaskType(string $taskProcessingTaskTypeCla */ public function registerMailProvider(string $class): void; + + /** + * Register an implementation of \OCP\Config\Lexicon\IConfigLexicon that + * will handle the config lexicon + * + * @param string $configLexiconClass + * + * @psalm-param class-string<\NCU\Config\Lexicon\IConfigLexicon> $configLexiconClass + * @since 31.0.0 + */ + public function registerConfigLexicon(string $configLexiconClass): void; } diff --git a/OCP/Calendar/ICalendar.php b/OCP/Calendar/ICalendar.php index f29d6f3..2dfc1ca 100644 --- a/OCP/Calendar/ICalendar.php +++ b/OCP/Calendar/ICalendar.php @@ -53,7 +53,7 @@ public function getDisplayColor(): ?string; public function search(string $pattern, array $searchProperties = [], array $options = [], ?int $limit = null, ?int $offset = null): array; /** - * @return int build up using \OCP\Constants + * @return int build up using {@see \OCP\Constants} * @since 13.0.0 */ public function getPermissions(): int; diff --git a/OCP/IAppConfig.php b/OCP/IAppConfig.php index fe894da..d4d5c1c 100644 --- a/OCP/IAppConfig.php +++ b/OCP/IAppConfig.php @@ -45,6 +45,9 @@ interface IAppConfig { /** @since 29.0.0 */ public const VALUE_ARRAY = 64; + /** @since 31.0.0 */ + public const FLAG_SENSITIVE = 1; // value is sensitive + /** * Get list of all apps that have at least one config value stored in database *