class UpdateRegistry (View source)

Provides all and missing update implementations.

Note: This registry is specific to a type of updates, like 'post_update' as example.

It therefore scans for functions named like the type of updates, so it looks like MODULE_UPDATETYPE_NAME() with NAME being a machine name.

Properties

protected string $updateType

The used update name.

protected string $root

The app root.

protected string $logFilename

The filename of the log file.

protected string[] $enabledModules
protected KeyValueStoreInterface $keyValue

The key value storage.

protected bool|null $includeTests

Should we respect update functions in tests.

protected string $sitePath

The site path.

Methods

__construct(string $root, string $site_path, array $enabled_modules, KeyValueStoreInterface $key_value, bool|null $include_tests = NULL)

Constructs a new UpdateRegistry.

string[]
getRemovedPostUpdates($module)

Gets removed hook_post_update_NAME() implementations for a module.

callable[]
getAvailableUpdateFunctions()

Gets all available update functions.

callable[]
getPendingUpdateFunctions()

Find all update functions that haven't been executed.

loadUpdateFiles(array $module_extensions)

Loads all update files for a given list of extension.

loadUpdateFile(Extension $module)

Loads the {$this->updateType}.php file for a given extension.

array[]
getPendingUpdateInformation()

Returns a list of all the pending updates.

$this
registerInvokedUpdates(array $function_names)

Registers that update functions were executed.

callable[]
getModuleUpdateFunctions(string $module_name)

Returns all available updates for a given module.

scanExtensionsAndLoadUpdateFiles()

Scans all module + profile extensions and load the update files.

filterOutInvokedUpdatesByModule(string $module)

Filters out already executed update functions by module.

Details

__construct(string $root, string $site_path, array $enabled_modules, KeyValueStoreInterface $key_value, bool|null $include_tests = NULL)

Constructs a new UpdateRegistry.

Parameters

string $root

The app root.

string $site_path

The site path.

array $enabled_modules

A list of enabled modules.

KeyValueStoreInterface $key_value

The key value store.

bool|null $include_tests

(optional) A flag whether to include tests in the scanning of modules.

string[] getRemovedPostUpdates($module)

Gets removed hook_post_update_NAME() implementations for a module.

Parameters

$module

Return Value

string[]

A list of post-update functions that have been removed.

protected callable[] getAvailableUpdateFunctions()

Gets all available update functions.

Return Value

callable[]

A list of update functions.

callable[] getPendingUpdateFunctions()

Find all update functions that haven't been executed.

Return Value

callable[]

A list of update functions.

protected loadUpdateFiles(array $module_extensions)

Loads all update files for a given list of extension.

Parameters

array $module_extensions

The extensions used for loading.

protected loadUpdateFile(Extension $module)

Loads the {$this->updateType}.php file for a given extension.

Parameters

Extension $module

The extension of the module to load its file.

array[] getPendingUpdateInformation()

Returns a list of all the pending updates.

Return Value

array[]

An associative array keyed by module name which contains all information about database updates that need to be run, and any updates that are not going to proceed due to missing requirements.

The subarray for each module can contain the following keys:

  • start: The starting update that is to be processed. If this does not exist then do not process any updates for this module as there are other requirements that need to be resolved.
  • pending: An array of all the pending updates for the module including the description from source code comment for each update function. This array is keyed by the update name.

$this registerInvokedUpdates(array $function_names)

Registers that update functions were executed.

Parameters

array $function_names

The executed update functions.

Return Value

$this

callable[] getModuleUpdateFunctions(string $module_name)

Returns all available updates for a given module.

Parameters

string $module_name

The module name.

Return Value

callable[]

A list of update functions.

protected scanExtensionsAndLoadUpdateFiles()

Scans all module + profile extensions and load the update files.

filterOutInvokedUpdatesByModule(string $module)

Filters out already executed update functions by module.

Parameters

string $module

The module name.