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

File

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

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 === SystemManager::REQUIREMENT_ERROR) {
            return SystemManager::REQUIREMENT_ERROR;
        }
    }
    // If there were no errors, then any remaining results must be warnings.
    return $results ? SystemManager::REQUIREMENT_WARNING : SystemManager::REQUIREMENT_OK;
}

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