diff options
author | Côme Chilliet <come.chilliet@nextcloud.com> | 2023-11-06 16:21:15 +0100 |
---|---|---|
committer | Côme Chilliet <come.chilliet@nextcloud.com> | 2023-11-07 14:15:47 +0100 |
commit | 39d2970191f88b0e9575e170e904a5c2214cb709 (patch) | |
tree | 25bfe751733e3831f454e8a3f87b5ff45d7961b7 /lib | |
parent | 00d3856b92aa533777907b990d76e98bb4d3c9dc (diff) | |
download | nextcloud-server-39d2970191f88b0e9575e170e904a5c2214cb709.tar.gz nextcloud-server-39d2970191f88b0e9575e170e904a5c2214cb709.zip |
Add $name property in SetupResult and improve API
Keys for check results are not locale dependent anymore, the name of the
setup check is instead stored in the setup result object.
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/SetupCheck/SetupCheckManager.php | 3 | ||||
-rw-r--r-- | lib/public/SetupCheck/ISetupCheck.php | 2 | ||||
-rw-r--r-- | lib/public/SetupCheck/SetupResult.php | 32 |
3 files changed, 36 insertions, 1 deletions
diff --git a/lib/private/SetupCheck/SetupCheckManager.php b/lib/private/SetupCheck/SetupCheckManager.php index f9e67772019..b8b6cfa11e7 100644 --- a/lib/private/SetupCheck/SetupCheckManager.php +++ b/lib/private/SetupCheck/SetupCheckManager.php @@ -47,9 +47,10 @@ class SetupCheckManager implements ISetupCheckManager { $setupCheckObject = Server::get($setupCheck->getService()); $this->logger->debug('Running check '.get_class($setupCheckObject)); $setupResult = $setupCheckObject->run(); + $setupResult->setName($setupCheckObject->getName()); $category = $setupCheckObject->getCategory(); $results[$category] ??= []; - $results[$category][$setupCheckObject->getName()] = $setupResult; + $results[$category][$setupCheckObject::class] = $setupResult; } return $results; } diff --git a/lib/public/SetupCheck/ISetupCheck.php b/lib/public/SetupCheck/ISetupCheck.php index 77eeaea4df1..96eb6ddd7da 100644 --- a/lib/public/SetupCheck/ISetupCheck.php +++ b/lib/public/SetupCheck/ISetupCheck.php @@ -36,11 +36,13 @@ namespace OCP\SetupCheck; interface ISetupCheck { /** * @since 28.0.0 + * @return string Category id, one of security/system/accounts, or a custom one which will be merged in system */ public function getCategory(): string; /** * @since 28.0.0 + * @return string Translated name to display to the user */ public function getName(): string; diff --git a/lib/public/SetupCheck/SetupResult.php b/lib/public/SetupCheck/SetupResult.php index 27026f82815..e4a7744178a 100644 --- a/lib/public/SetupCheck/SetupResult.php +++ b/lib/public/SetupCheck/SetupResult.php @@ -38,6 +38,11 @@ class SetupResult implements \JsonSerializable { public const ERROR = 'error'; /** + * @param string $name Translated name to display to the user + */ + private ?string $name = null; + + /** * @brief Private constructor, use success()/info()/warning()/error() instead * @param self::SUCCESS|self::INFO|self::WARNING|self::ERROR $severity * @since 28.0.0 @@ -51,6 +56,8 @@ class SetupResult implements \JsonSerializable { /** * @brief Create a success result object + * @param ?string $description Translated detailed description to display to the user + * @param ?string $linkToDoc URI of related relevent documentation, be it from Nextcloud or another project * @since 28.0.0 */ public static function success(?string $description = null, ?string $linkToDoc = null): self { @@ -59,6 +66,8 @@ class SetupResult implements \JsonSerializable { /** * @brief Create an info result object + * @param ?string $description Translated detailed description to display to the user + * @param ?string $linkToDoc URI of related relevent documentation, be it from Nextcloud or another project * @since 28.0.0 */ public static function info(?string $description = null, ?string $linkToDoc = null): self { @@ -67,6 +76,8 @@ class SetupResult implements \JsonSerializable { /** * @brief Create a warning result object + * @param ?string $description Translated detailed description to display to the user + * @param ?string $linkToDoc URI of related relevent documentation, be it from Nextcloud or another project * @since 28.0.0 */ public static function warning(?string $description = null, ?string $linkToDoc = null): self { @@ -75,6 +86,8 @@ class SetupResult implements \JsonSerializable { /** * @brief Create an error result object + * @param ?string $description Translated detailed description to display to the user + * @param ?string $linkToDoc URI of related relevent documentation, be it from Nextcloud or another project * @since 28.0.0 */ public static function error(?string $description = null, ?string $linkToDoc = null): self { @@ -101,6 +114,24 @@ class SetupResult implements \JsonSerializable { } /** + * @brief Get the name for the setup check + * + * @since 28.0.0 + */ + public function getName(): ?string { + return $this->name; + } + + /** + * @brief Set the name from the setup check + * + * @since 28.0.0 + */ + public function setName(string $name): void { + $this->name = $name; + } + + /** * @brief Get a link to the doc for the explanation. * * @since 28.0.0 @@ -116,6 +147,7 @@ class SetupResult implements \JsonSerializable { */ public function jsonSerialize(): array { return [ + 'name' => $this->name, 'severity' => $this->severity, 'description' => $this->description, 'linkToDoc' => $this->linkToDoc, |