class UpdateHookRegistry (View source)

Provides module updates versions handling.

Constants

SCHEMA_UNINSTALLED

Indicates that a module has not been installed yet.

Properties

protected string[] $enabledModules

A list of enabled modules.

protected KeyValueStoreInterface $keyValue

The key value storage.

protected int[][] $allAvailableSchemaVersions

A static cache of schema currentVersions per module.

Methods

__construct(array $enabled_modules, KeyValueStoreInterface $key_value)

Constructs a new UpdateRegistry.

array
getAvailableUpdates(string $module)

Returns an array of available schema versions for a module.

int
getInstalledVersion(string $module)

Returns the currently installed schema version for a module.

setInstalledVersion(string $module, int $version)

Updates the installed version information for a module.

void
deleteInstalledVersion(string $module)

Deletes the installed version information for the module.

array
getAllInstalledVersions()

Returns the currently installed schema version for all modules.

Details

__construct(array $enabled_modules, KeyValueStoreInterface $key_value)

Constructs a new UpdateRegistry.

Parameters

array $enabled_modules

A list of enabled modules.

KeyValueStoreInterface $key_value

The key value store.

array getAvailableUpdates(string $module)

Returns an array of available schema versions for a module.

Parameters

string $module

A module name.

Return Value

array

An array of available updates sorted by version. Empty array returned if no updates available.

int getInstalledVersion(string $module)

Returns the currently installed schema version for a module.

Parameters

string $module

A module name.

Return Value

int

The currently installed schema version, or self::SCHEMA_UNINSTALLED if the module is not installed.

UpdateHookRegistry setInstalledVersion(string $module, int $version)

Updates the installed version information for a module.

Parameters

string $module

A module name.

int $version

The new schema version.

Return Value

UpdateHookRegistry

Returns self to support chained method calls.

void deleteInstalledVersion(string $module)

Deletes the installed version information for the module.

Parameters

string $module

The module name to delete.

Return Value

void

array getAllInstalledVersions()

Returns the currently installed schema version for all modules.

Return Value

array

Array of modules as the keys and values as the currently installed schema version of corresponding module, or self::SCHEMA_UNINSTALLED if the module is not installed.