You are here

public static function UpdateManager::toSemanticVersion in Lightning Core 8.2

Same name and namespace in other branches
  1. 8.5 src/UpdateManager.php \Drupal\lightning_core\UpdateManager::toSemanticVersion()
  2. 8 src/UpdateManager.php \Drupal\lightning_core\UpdateManager::toSemanticVersion()
  3. 8.3 src/UpdateManager.php \Drupal\lightning_core\UpdateManager::toSemanticVersion()
  4. 8.4 src/UpdateManager.php \Drupal\lightning_core\UpdateManager::toSemanticVersion()

Converts a drupal.org version number to a semantic version.

Parameters

string $version: The drupal.org version number, e.g. 8.x-1.12.

Return value

string The version number in semantic version format.

2 calls to UpdateManager::toSemanticVersion()
UpdateManager::getVersion in src/UpdateManager.php
Tries to determine the semantic version of a module.
UpdateManagerTest::testSemanticVersion in tests/src/Unit/UpdateManagerTest.php
@covers ::toSemanticVersion

File

src/UpdateManager.php, line 113

Class

UpdateManager

Namespace

Drupal\lightning_core

Code

public static function toSemanticVersion($version) {

  // Strip the 8.x prefix from the version.
  $semantic_version = preg_replace('/^' . \Drupal::CORE_COMPATIBILITY . '-/', NULL, $version);
  if (preg_match('/-dev$/', $semantic_version)) {
    return preg_replace('/^(\\d).+-dev$/', '$1.x-dev', $semantic_version);
  }
  else {
    return preg_replace('/^(\\d+\\.\\d+)(-.+)?$/', '$1.0$2', $semantic_version);
  }
}