function HookCollectorPass::calculateImplementations

Calculates the ordered implementations.

Return value

array<string, array<string, string>> Implementations, as module names keyed by hook name and "$class::$method" identifier.

1 call to HookCollectorPass::calculateImplementations()
HookCollectorPass::writeToContainer in core/lib/Drupal/Core/Hook/HookCollectorPass.php
Writes collected definitions to the container builder.

File

core/lib/Drupal/Core/Hook/HookCollectorPass.php, line 224

Class

HookCollectorPass
Collects and registers hook implementations.

Namespace

Drupal\Core\Hook

Code

protected function calculateImplementations() : array {
    $implementationsByHookOrig = $this->getFilteredImplementations();
    // List of hooks and modules formatted for hook_module_implements_alter().
    $moduleImplementsMap = [];
    foreach ($implementationsByHookOrig as $hook => $hookImplementations) {
        foreach (array_intersect($this->modules, $hookImplementations) as $module) {
            $moduleImplementsMap[$hook][$module] = '';
        }
    }
    $implementationsByHook = [];
    foreach ($moduleImplementsMap as $hook => $moduleImplements) {
        // Process all hook_module_implements_alter() for build time ordering.
        foreach ($this->moduleImplementsAlters as $alter) {
            $alter($moduleImplements, $hook);
        }
        foreach ($moduleImplements as $module => $v) {
            if (is_string($hook) && str_starts_with($hook, 'preprocess_') && str_contains($hook, '__')) {
                $this->preprocessForSuggestions[$module . '_' . $hook] = TRUE;
            }
            foreach (array_keys($implementationsByHookOrig[$hook], $module, TRUE) as $identifier) {
                $implementationsByHook[$hook][$identifier] = $module;
            }
        }
    }
    foreach ($this->getOrderOperations() as $hook => $order_operations) {
        self::applyOrderOperations($implementationsByHook[$hook], $order_operations);
    }
    return $implementationsByHook;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.