You are here

public function UpdateManager::getVersion in Lightning Core 8

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

Tries to determine the semantic version of a module.

Parameters

string $module: The machine name of the module.

Return value

string The semantic version of the module, or static::VERSION_UNKNOWN if it could not be determined.

File

src/UpdateManager.php, line 89

Class

UpdateManager

Namespace

Drupal\lightning_core

Code

public function getVersion($module) {
  $info = system_get_info('module', $module);
  if (isset($info['version'])) {
    return static::toSemanticVersion($info['version']);
  }
  else {

    // Follow core's model and try to determine the target version of the
    // most recent update.
    $updates = $this
      ->getDefinitions($module);
    return $updates ? end($updates)['id'] : static::VERSION_UNKNOWN;
  }
}