function HookCollectorPass::registerHookServices

Registers the hook implementation services.

Parameters

\Symfony\Component\DependencyInjection\ContainerBuilder $container: The container builder.

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

1 call to HookCollectorPass::registerHookServices()
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 371

Class

HookCollectorPass
Collects and registers hook implementations.

Namespace

Drupal\Core\Hook

Code

protected static function registerHookServices(ContainerBuilder $container, array $implementationsByHook) : void {
  $classesMap = [];
  foreach ($implementationsByHook as $hookImplementations) {
    foreach (array_keys($hookImplementations) as $identifier) {
      $parts = explode('::', $identifier, 2);
      if (isset($parts[1])) {
        $classesMap[$parts[0]] = TRUE;
      }
    }
  }
  foreach (array_keys($classesMap) as $class) {
    if (!$container->hasDefinition($class)) {
      $container->register($class, $class)
        ->setAutowired(TRUE);
    }
  }
}

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