You are here

protected function ProjectCoreCompatibility::getPossibleCoreUpdateVersions in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/update/src/ProjectCoreCompatibility.php \Drupal\update\ProjectCoreCompatibility::getPossibleCoreUpdateVersions()
  2. 10 core/modules/update/src/ProjectCoreCompatibility.php \Drupal\update\ProjectCoreCompatibility::getPossibleCoreUpdateVersions()

Gets the core versions that should be considered for compatibility ranges.

Parameters

array $core_releases: The Drupal core available releases.

Return value

string[] The core version numbers that are possible to update the site to.

1 call to ProjectCoreCompatibility::getPossibleCoreUpdateVersions()
ProjectCoreCompatibility::__construct in core/modules/update/src/ProjectCoreCompatibility.php
Constructs a ProjectCoreCompatibility object.

File

core/modules/update/src/ProjectCoreCompatibility.php, line 78

Class

ProjectCoreCompatibility
Utility class to set core compatibility messages for project releases.

Namespace

Drupal\update

Code

protected function getPossibleCoreUpdateVersions(array $core_releases) {
  if (!isset($core_releases[$this->existingCoreVersion])) {

    // If we can't determine the existing version of core then we can't
    // calculate the core compatibility of a given release based on core
    // versions after the existing version.
    return [];
  }
  $core_release_versions = array_keys($core_releases);
  $possible_core_update_versions = Semver::satisfiedBy($core_release_versions, '>= ' . $this->existingCoreVersion);
  $possible_core_update_versions = Semver::sort($possible_core_update_versions);
  $possible_core_update_versions = array_filter($possible_core_update_versions, function ($version) {
    return VersionParser::parseStability($version) === 'stable';
  });
  return $possible_core_update_versions;
}