class ValidationResult in Automatic Updates 8.2
A value object to contain the results of a validation.
Hierarchy
- class \Drupal\automatic_updates\Validation\ValidationResult
Expanded class hierarchy of ValidationResult
15 files declare their use of ValidationResult
- ComposerExecutableValidator.php in src/
Validator/ ComposerExecutableValidator.php - ComposerExecutableValidatorTest.php in tests/
src/ Kernel/ ReadinessValidation/ ComposerExecutableValidatorTest.php - CoreComposerValidator.php in src/
Validator/ CoreComposerValidator.php - CoreComposerValidatorTest.php in tests/
src/ Kernel/ ReadinessValidation/ CoreComposerValidatorTest.php - DiskSpaceValidator.php in src/
Validator/ DiskSpaceValidator.php
File
- src/
Validation/ ValidationResult.php, line 11
Namespace
Drupal\automatic_updates\ValidationView source
class ValidationResult {
/**
* A succinct summary of the results.
*
* @var \Drupal\Core\StringTranslation\TranslatableMarkup
*/
protected $summary;
/**
* The error messages.
*
* @var \Drupal\Core\StringTranslation\TranslatableMarkup[]
*/
protected $messages;
/**
* The severity of the result.
*
* @var int
*/
protected $severity;
/**
* Creates a ValidationResult object.
*
* @param int $severity
* The severity of the result. Should be one of the
* SystemManager::REQUIREMENT_* constants.
* @param \Drupal\Core\StringTranslation\TranslatableMarkup[] $messages
* The error messages.
* @param \Drupal\Core\StringTranslation\TranslatableMarkup|null $summary
* The errors summary.
*/
private function __construct(int $severity, array $messages, ?TranslatableMarkup $summary = NULL) {
if (count($messages) > 1 && !$summary) {
throw new \InvalidArgumentException('If more than one message is provided, a summary is required.');
}
$this->summary = $summary;
$this->messages = $messages;
$this->severity = $severity;
}
/**
* Creates an error ValidationResult object.
*
* @param \Drupal\Core\StringTranslation\TranslatableMarkup[] $messages
* The error messages.
* @param \Drupal\Core\StringTranslation\TranslatableMarkup|null $summary
* The errors summary.
*
* @return static
*/
public static function createError(array $messages, ?TranslatableMarkup $summary = NULL) : self {
return new static(SystemManager::REQUIREMENT_ERROR, $messages, $summary);
}
/**
* Creates a warning ValidationResult object.
*
* @param \Drupal\Core\StringTranslation\TranslatableMarkup[] $messages
* The error messages.
* @param \Drupal\Core\StringTranslation\TranslatableMarkup|null $summary
* The errors summary.
*
* @return static
*/
public static function createWarning(array $messages, ?TranslatableMarkup $summary = NULL) : self {
return new static(SystemManager::REQUIREMENT_WARNING, $messages, $summary);
}
/**
* Gets the summary.
*
* @return \Drupal\Core\StringTranslation\TranslatableMarkup|null
* The summary.
*/
public function getSummary() : ?TranslatableMarkup {
return $this->summary;
}
/**
* Gets the messages.
*
* @return \Drupal\Core\StringTranslation\TranslatableMarkup[]
* The error or warning messages.
*/
public function getMessages() : array {
return $this->messages;
}
/**
* The severity of the result.
*
* @return int
* Either SystemManager::REQUIREMENT_ERROR or
* SystemManager::REQUIREMENT_WARNING.
*/
public function getSeverity() : int {
return $this->severity;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ValidationResult:: |
protected | property | The error messages. | |
ValidationResult:: |
protected | property | The severity of the result. | |
ValidationResult:: |
protected | property | A succinct summary of the results. | |
ValidationResult:: |
public static | function | Creates an error ValidationResult object. | |
ValidationResult:: |
public static | function | Creates a warning ValidationResult object. | |
ValidationResult:: |
public | function | Gets the messages. | |
ValidationResult:: |
public | function | The severity of the result. | |
ValidationResult:: |
public | function | Gets the summary. | |
ValidationResult:: |
private | function | Creates a ValidationResult object. |