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

Breadcrumb

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

function UpdateHookRegistry::determineModuleAndVersion

Determines the module and update number from the stack trace.

Return value

array<string, int> An array with two values. The first value is the module name and the second value is the update number.

2 calls to UpdateHookRegistry::determineModuleAndVersion()
UpdateHookRegistry::getEquivalentUpdate in core/lib/Drupal/Core/Update/UpdateHookRegistry.php
Gets the EquivalentUpdate object for an update.
UpdateHookRegistry::markFutureUpdateEquivalent in core/lib/Drupal/Core/Update/UpdateHookRegistry.php
Marks a future update as equivalent to the current update running.

File

core/lib/Drupal/Core/Update/UpdateHookRegistry.php, line 267

Class

UpdateHookRegistry
Provides module updates versions handling.

Namespace

Drupal\Core\Update

Code

private function determineModuleAndVersion() : array {
    $stack = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
    for ($i = 0; $i < count($stack); $i++) {
        if (preg_match(self::FUNC_NAME_REGEXP, $stack[$i]['function'], $matches)) {
            return [
                $matches['module'],
                $matches['version'],
            ];
        }
    }
    throw new \BadMethodCallException(__METHOD__ . ' must be called from a hook_update_N() function');
}

API Navigation

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