function SupportedReleaseValidator::isSupportedRelease

Checks if the given version of a project is supported.

Checks if the given version of the given project is in the core update system's list of known, secure, installable releases of that project. considered a supported release by verifying if the project is found in the core update system's list of known, secure, and installable releases.

Parameters

string $name: The name of the project.

string $semantic_version: A semantic version number for the project.

Return value

bool TRUE if the given version of the project is supported, otherwise FALSE. given version is not supported will return FALSE.

1 call to SupportedReleaseValidator::isSupportedRelease()
SupportedReleaseValidator::validate in core/modules/package_manager/src/Validator/SupportedReleaseValidator.php
Checks that the packages are secure and supported.

File

core/modules/package_manager/src/Validator/SupportedReleaseValidator.php, line 48

Class

SupportedReleaseValidator
Validates that updated projects are secure and supported.

Namespace

Drupal\package_manager\Validator

Code

private function isSupportedRelease(string $name, string $semantic_version) : bool {
    $supported_releases = (new ProjectInfo($name))->getInstallableReleases();
    if (!$supported_releases) {
        return FALSE;
    }
    // If this version is found in the list of installable releases, it is
    // secured and supported.
    if (array_key_exists($semantic_version, $supported_releases)) {
        return TRUE;
    }
    // If the semantic version number wasn't in the list of
    // installable releases, convert it to a legacy version number and see
    // if the version number is in the list.
    $legacy_version = LegacyVersionUtility::convertToLegacyVersion($semantic_version);
    if ($legacy_version && array_key_exists($legacy_version, $supported_releases)) {
        return TRUE;
    }
    // Neither the semantic version nor the legacy version are in the list
    // of installable releases, so the release isn't supported.
    return FALSE;
}

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