function HookCollectorPass::convertProceduralToImplementations

Converts procedural hooks to attribute based hooks.

Return value

$this

File

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

Class

HookCollectorPass
Collects and registers hook implementations.

Namespace

Drupal\Core\Hook

Code

protected function convertProceduralToImplementations() : static {
    foreach ($this->proceduralHooks as $hook => $hook_implementations) {
        // A hook can be all numbers and because it was put into an array index
        // it might get cast into a number which might fail a
        // hook_module_implements_alter() and is guaranteed to fail the Hook
        // attribute constructor.
        $hook = (string) $hook;
        if ($hook !== 'module_implements_alter') {
            foreach ($this->moduleImplementsAlters as $alter) {
                $alter($hook_implementations, $hook);
            }
        }
        foreach ($hook_implementations as $module => $group) {
            $this->addFromAttribute(new Hook($hook, $module . '_' . $hook), ProceduralCall::class, $module);
        }
    }
    return $this;
}

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