function ValidationResult::getOverallSeverity

Returns the overall severity for a set of validation results.

Parameters

\Drupal\package_manager\ValidationResult[] $results: The validation results.

Return value

int The overall severity of the results. Will be one of the SystemManager::REQUIREMENT_* constants.

1 call to ValidationResult::getOverallSeverity()
ValidationResultTest::testOverallSeverity in core/modules/package_manager/tests/src/Unit/ValidationResultTest.php
@covers ::getOverallSeverity[[api-linebreak]]

File

core/modules/package_manager/src/ValidationResult.php, line 121

Class

ValidationResult
A value object to contain the results of a validation.

Namespace

Drupal\package_manager

Code

public static function getOverallSeverity(array $results) : int {
  foreach ($results as $result) {
    if ($result->severity === RequirementSeverity::Error->value) {
      return RequirementSeverity::Error->value;
    }
  }
  // If there were no errors, then any remaining results must be warnings.
  return $results ? RequirementSeverity::Warning->value : RequirementSeverity::OK->value;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.