You are here

protected static function InfoParserDynamic::getAllPreviousCoreVersions in Drupal 8

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Extension/InfoParserDynamic.php \Drupal\Core\Extension\InfoParserDynamic::getAllPreviousCoreVersions()

Gets all the versions of Drupal 8 before a specific version.

Parameters

string $version: The version to get versions before.

Return value

array All of the applicable Drupal 8 releases.

1 call to InfoParserDynamic::getAllPreviousCoreVersions()
InfoParserDynamic::isConstraintSatisfiedByPreviousVersion in core/lib/Drupal/Core/Extension/InfoParserDynamic.php
Determines if a constraint is satisfied by earlier versions of Drupal 8.

File

core/lib/Drupal/Core/Extension/InfoParserDynamic.php, line 181

Class

InfoParserDynamic
Parses dynamic .info.yml files that might change during the page request.

Namespace

Drupal\Core\Extension

Code

protected static function getAllPreviousCoreVersions($version) {
  static $versions_lists = [];

  // Check if list of previous versions for the specified version has already
  // been created.
  if (empty($versions_lists[$version])) {

    // Loop through all minor versions including 8.7.
    foreach (range(0, 7) as $minor) {

      // The largest patch number in a release was 17 in 8.6.17. Use 27 to
      // leave room for future security releases.
      foreach (range(0, 27) as $patch) {
        $patch_version = "8.{$minor}.{$patch}";
        if ($patch_version === $version) {

          // Reverse the order of the versions so that they will be evaluated
          // from the most recent versions first.
          $versions_lists[$version] = array_reverse($versions_lists[$version]);
          return $versions_lists[$version];
        }
        if ($patch === 0) {

          // If this is a '0' patch release like '8.1.0' first create the
          // pre-release versions such as '8.1.0-alpha1' and '8.1.0-rc1'.
          foreach ([
            'alpha',
            'beta',
            'rc',
          ] as $prerelease) {

            // The largest prerelease number was  in 8.0.0-beta16.
            foreach (range(0, 16) as $prerelease_number) {
              $versions_lists[$version][] = "{$patch_version}-{$prerelease}{$prerelease_number}";
            }
          }
        }
        $versions_lists[$version][] = $patch_version;
      }
    }
  }
  return $versions_lists[$version];
}