Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. UpdateRegistry.php

function UpdateRegistry::getAvailableUpdateFunctions

Gets all available update functions.

Return value

callable[] An alphabetical list of available update functions.

1 call to UpdateRegistry::getAvailableUpdateFunctions()
UpdateRegistry::getPendingUpdateFunctions in core/lib/Drupal/Core/Update/UpdateRegistry.php
Find all update functions that haven't been executed.

File

core/lib/Drupal/Core/Update/UpdateRegistry.php, line 96

Class

UpdateRegistry
Provides all and missing update implementations.

Namespace

Drupal\Core\Update

Code

protected function getAvailableUpdateFunctions() {
    $regexp = '/^(?<extension>.+)_' . $this->updateType . '_(?<name>.+)$/';
    $functions = get_defined_functions();
    $updates = [];
    foreach (preg_grep('/_' . $this->updateType . '_/', $functions['user']) as $function) {
        // If this function is an extension update function, add it to the list of
        // extension updates.
        if (preg_match($regexp, $function, $matches)) {
            if (in_array($matches['extension'], $this->enabledExtensions)) {
                $function_name = $matches['extension'] . '_' . $this->updateType . '_' . $matches['name'];
                if ($this->updateType === 'post_update') {
                    $removed = array_keys($this->getRemovedPostUpdates($matches['extension']));
                    if (array_search($function_name, $removed) !== FALSE) {
                        throw new RemovedPostUpdateNameException(sprintf('The following update is specified as removed in hook_removed_post_updates() but still exists in the code base: %s', $function_name));
                    }
                }
                $updates[] = $function_name;
            }
        }
    }
    // Ensure that the update order is deterministic.
    sort($updates);
    return $updates;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal