You are here

public function UpdateManager::getVersion in Lightning Core 8.5

Same name and namespace in other branches
  1. 8 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 103

Class

UpdateManager
Discovers and manages optional configuration updates.

Namespace

Drupal\lightning_core

Code

public function getVersion($module) {
  $info = $this->moduleExtensionList
    ->getAllAvailableInfo();
  if (isset($info[$module]['version'])) {
    return static::toSemanticVersion($info[$module]['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;
  }
}