function HookCollectorBase::registerHookServices
Registers hook implementation services.
Parameters
\Symfony\Component\DependencyInjection\ContainerBuilder $container: The container builder.
array<string, array<string, string>> $implementations_by_hook: Implementations keyed by hook name and identifier.
2 calls to HookCollectorBase::registerHookServices()
- HookCollectorPass::writeToContainer in core/
lib/ Drupal/ Core/ Hook/ HookCollectorPass.php - Writes collected definitions to the container builder.
- ThemeHookCollectorPass::writeToContainer in core/
lib/ Drupal/ Core/ Hook/ ThemeHookCollectorPass.php - Writes collected definitions to the container builder.
File
-
core/
lib/ Drupal/ Core/ Hook/ HookCollectorBase.php, line 56
Class
- HookCollectorBase
- Provides shared hook collection functionality.
Namespace
Drupal\Core\HookCode
protected static function registerHookServices(ContainerBuilder $container, array $implementations_by_hook) : void {
$classes_map = [];
foreach ($implementations_by_hook as $hook_implementations) {
foreach (array_keys($hook_implementations) as $identifier) {
$parts = explode('::', $identifier, 2);
if (isset($parts[1])) {
$classes_map[$parts[0]] = TRUE;
}
}
}
foreach (array_keys($classes_map) 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.