function HookCollectorPass::writeToContainer
Same name and namespace in other branches
- 11.x core/lib/Drupal/Core/Hook/HookCollectorPass.php \Drupal\Core\Hook\HookCollectorPass::writeToContainer()
Writes collected definitions to the container builder.
Parameters
\Symfony\Component\DependencyInjection\ContainerBuilder $container: Container builder.
File
-
core/
lib/ Drupal/ Core/ Hook/ HookCollectorPass.php, line 125
Class
- HookCollectorPass
- Collects and registers hook implementations.
Namespace
Drupal\Core\HookCode
protected function writeToContainer(ContainerBuilder $container) : void {
$implementationsByHook = $this->calculateImplementations();
static::registerHookServices($container, $implementationsByHook);
$packed_order_operations = [];
$order_operations = $this->getOrderOperations();
foreach (preg_grep('@_alter$@', array_keys($order_operations)) as $alter_hook) {
$packed_order_operations[$alter_hook] = array_map(fn(OrderOperation $operation) => $operation->pack(), $order_operations[$alter_hook]);
}
// Write aggregated data about hooks into a temporary parameter.
// We use a dot prefixed parameter so it will automatically get cleaned up.
// This will be stored in a keyvalue store in
// \Drupal\Core\Hook\HookCollectorKeyValueWritePass.
$container->setParameter('.hook_data', [
'hook_list' => $implementationsByHook,
'preprocess_for_suggestions' => $this->preprocessForSuggestions ?? [],
'packed_order_operations' => $packed_order_operations,
]);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.