|
|
|
@ -26,6 +26,8 @@ declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
namespace OCP\SetupCheck;
|
|
|
|
|
|
|
|
|
|
use OCP\RichObjectStrings\IValidator;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief This class is used for storing the result of a setup check
|
|
|
|
|
*
|
|
|
|
@ -46,12 +48,18 @@ class SetupResult implements \JsonSerializable {
|
|
|
|
|
* @brief Private constructor, use success()/info()/warning()/error() instead
|
|
|
|
|
* @param self::SUCCESS|self::INFO|self::WARNING|self::ERROR $severity
|
|
|
|
|
* @since 28.0.0
|
|
|
|
|
* @since 28.0.2 Optional parameter ?array $descriptionParameters
|
|
|
|
|
* @since 28.0.2 throws \OCP\RichObjectStrings\InvalidObjectExeption
|
|
|
|
|
*/
|
|
|
|
|
private function __construct(
|
|
|
|
|
private string $severity,
|
|
|
|
|
private ?string $description = null,
|
|
|
|
|
private ?array $descriptionParameters = null,
|
|
|
|
|
private ?string $linkToDoc = null,
|
|
|
|
|
) {
|
|
|
|
|
if ($description !== null && $descriptionParameters !== null) {
|
|
|
|
|
\OCP\Server::get(IValidator::class)->validate($description, $descriptionParameters);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -59,9 +67,10 @@ class SetupResult implements \JsonSerializable {
|
|
|
|
|
* @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
|
|
|
|
|
* @since 28.0.2 Optional parameter ?array $descriptionParameters
|
|
|
|
|
*/
|
|
|
|
|
public static function success(?string $description = null, ?string $linkToDoc = null): self {
|
|
|
|
|
return new self(self::SUCCESS, $description, $linkToDoc);
|
|
|
|
|
public static function success(?string $description = null, ?string $linkToDoc = null, ?array $descriptionParameters = null): self {
|
|
|
|
|
return new self(self::SUCCESS, $description, $descriptionParameters, $linkToDoc);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -69,9 +78,10 @@ class SetupResult implements \JsonSerializable {
|
|
|
|
|
* @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
|
|
|
|
|
* @since 28.0.2 Optional parameter ?array $descriptionParameters
|
|
|
|
|
*/
|
|
|
|
|
public static function info(?string $description = null, ?string $linkToDoc = null): self {
|
|
|
|
|
return new self(self::INFO, $description, $linkToDoc);
|
|
|
|
|
public static function info(?string $description = null, ?string $linkToDoc = null, ?array $descriptionParameters = null): self {
|
|
|
|
|
return new self(self::INFO, $description, $descriptionParameters, $linkToDoc);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -79,9 +89,10 @@ class SetupResult implements \JsonSerializable {
|
|
|
|
|
* @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
|
|
|
|
|
* @since 28.0.2 Optional parameter ?array $descriptionParameters
|
|
|
|
|
*/
|
|
|
|
|
public static function warning(?string $description = null, ?string $linkToDoc = null): self {
|
|
|
|
|
return new self(self::WARNING, $description, $linkToDoc);
|
|
|
|
|
public static function warning(?string $description = null, ?string $linkToDoc = null, ?array $descriptionParameters = null): self {
|
|
|
|
|
return new self(self::WARNING, $description, $descriptionParameters, $linkToDoc);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -89,9 +100,10 @@ class SetupResult implements \JsonSerializable {
|
|
|
|
|
* @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
|
|
|
|
|
* @since 28.0.2 Optional parameter ?array $descriptionParameters
|
|
|
|
|
*/
|
|
|
|
|
public static function error(?string $description = null, ?string $linkToDoc = null): self {
|
|
|
|
|
return new self(self::ERROR, $description, $linkToDoc);
|
|
|
|
|
public static function error(?string $description = null, ?string $linkToDoc = null, ?array $descriptionParameters = null): self {
|
|
|
|
|
return new self(self::ERROR, $description, $descriptionParameters, $linkToDoc);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -113,6 +125,17 @@ class SetupResult implements \JsonSerializable {
|
|
|
|
|
return $this->description;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Get the description parameters for the setup check result
|
|
|
|
|
*
|
|
|
|
|
* If this returns null, description must not be treated as rich text
|
|
|
|
|
*
|
|
|
|
|
* @since 28.0.2
|
|
|
|
|
*/
|
|
|
|
|
public function getDescriptionParameters(): ?array {
|
|
|
|
|
return $this->descriptionParameters;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Get the name for the setup check
|
|
|
|
|
*
|
|
|
|
@ -150,6 +173,7 @@ class SetupResult implements \JsonSerializable {
|
|
|
|
|
'name' => $this->name,
|
|
|
|
|
'severity' => $this->severity,
|
|
|
|
|
'description' => $this->description,
|
|
|
|
|
'descriptionParameters' => $this->descriptionParameters,
|
|
|
|
|
'linkToDoc' => $this->linkToDoc,
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|