function HookCollectorPass::addProceduralImplementation

Adds a procedural hook implementation.

Parameters

\SplFileInfo $fileinfo: The file this procedural implementation is in.

string $hook: The name of the hook.

string $module: The module implementing the hook, or on behalf of which the hook is implemented.

1 call to HookCollectorPass::addProceduralImplementation()
HookCollectorPass::collectModuleHookImplementations in core/lib/Drupal/Core/Hook/HookCollectorPass.php
Collects procedural and Attribute hook implementations.

File

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

Class

HookCollectorPass
Collects and registers hook implementations.

Namespace

Drupal\Core\Hook

Code

protected function addProceduralImplementation(\SplFileInfo $fileinfo, string $hook, string $module) : void {
  $function = $module . '_' . $hook;
  if ($hook === 'hook_info') {
    $this->hookInfo[] = $function;
    include_once $fileinfo->getPathname();
  }
  elseif ($hook === 'module_implements_alter') {
    $message = "{$function} without a #[LegacyModuleImplementsAlter] attribute is deprecated in drupal:11.2.0 and removed in drupal:12.0.0. See https://www.drupal.org/node/3496788";
    @trigger_error($message, E_USER_DEPRECATED);
    $this->moduleImplementsAlters[] = $function;
    include_once $fileinfo->getPathname();
  }
  $this->proceduralImplementations[$hook][] = $module;
  if ($fileinfo->getExtension() !== 'module') {
    $this->includes[$function] = $fileinfo->getPathname();
  }
}

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