class HookCollectorKeyValueWritePass
Same name and namespace in other branches
- 11.x core/lib/Drupal/Core/Hook/HookCollectorKeyValueWritePass.php \Drupal\Core\Hook\HookCollectorKeyValueWritePass
Stores hook implementations in keyvalue and clears cache.
This is done in a separate, late compiler pass to ensure that a possibly altered keyvalue service is respected.
@internal
Hierarchy
- class \Drupal\Core\Hook\HookCollectorKeyValueWritePass implements \Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface
Expanded class hierarchy of HookCollectorKeyValueWritePass
See also
\Drupal\Core\Hook\HookCollectorPass::writeToContainer
2 files declare their use of HookCollectorKeyValueWritePass
- CoreServiceProvider.php in core/
lib/ Drupal/ Core/ CoreServiceProvider.php - HookCollectorPassTest.php in core/
tests/ Drupal/ KernelTests/ Core/ Hook/ HookCollectorPassTest.php
File
-
core/
lib/ Drupal/ Core/ Hook/ HookCollectorKeyValueWritePass.php, line 21
Namespace
Drupal\Core\HookView source
class HookCollectorKeyValueWritePass implements CompilerPassInterface {
/**
* {@inheritdoc}
*/
public function process(ContainerBuilder $container) : void {
$hookData = $container->getParameter('.hook_data');
if ($container->hasParameter('.theme_hook_data')) {
$themeHookData = $container->getParameter('.theme_hook_data');
$hookData = array_merge($hookData, $themeHookData);
$hookData['preprocess_for_suggestions'] = array_merge($hookData['preprocess_for_suggestions'], $hookData['theme_preprocess_for_suggestions']);
}
$keyvalue = $container->get('keyvalue')
->get('hook_data');
assert($keyvalue instanceof KeyValueStoreInterface);
$keyvalue->setMultiple($hookData);
$container->get('cache.bootstrap')
->deleteMultiple([
'hook_data',
'theme_hook_data',
]);
// Remove converted flags, they are only needed while building the
// container.
$parameters = $container->getParameterBag();
foreach ($parameters->all() as $name => $value) {
if (str_ends_with($name, '.skip_procedural_hook_scan')) {
$parameters->remove($name);
}
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.