protected function ModuleCommands::getAvailableSchemaVersions in Helper 8
Returns a list of possible schema versions for a module.
Parameters
string $module: The module name.
Return value
int[] An array of schema versions.
1 call to ModuleCommands::getAvailableSchemaVersions()
- ModuleCommands::interactSchemaVersion in src/
Commands/ ModuleCommands.php - Sets the schema version for module.
File
- src/
Commands/ ModuleCommands.php, line 346
Class
- ModuleCommands
- Drush commands for working with module schemas.
Namespace
Drupal\helper\CommandsCode
protected function getAvailableSchemaVersions($module) {
module_load_install($module);
$versions = drupal_get_schema_versions($module);
if (!$versions) {
$versions = [];
}
// Add the minimum schema version available, which is either the value from
// hook_update_last_removed(), or the n000 where n is the major Drupal
// version number, since that is the schema version modules receive by
// default when they are installed.
$minimum_version = $this->moduleHandler
->invoke($module, 'update_last_removed') ?? drush_drupal_major_version() * 1000;
array_unshift($versions, $minimum_version);
// Add the current version minus one as an option.
$current_version = drupal_get_installed_schema_version($module);
if ($current_version > 0 && $current_version - 1 > $minimum_version) {
$versions[] = $current_version - 1;
}
// Filter out the current version as well as any versions below the last
// removed version.
$versions = array_filter($versions, function ($version) use ($current_version, $minimum_version) {
return $version != $current_version && $version >= $minimum_version;
});
// Unique and sort the options.
$versions = array_unique($versions);
sort($versions);
return $versions;
}