function KernelTestCompilerPass::process
File
-
core/
tests/ Drupal/ KernelTests/ KernelTestCompilerPass.php, line 29
Class
- KernelTestCompilerPass
- Adds hooks from kernel test to event dispatcher and module handler.
Namespace
Drupal\KernelTestsCode
public function process(ContainerBuilder $container) : void {
$map = $container->getParameter('.hook_data');
// Check for #[Hook] on methods.
$reflection_class = new \ReflectionClass($this->definition
->getClass());
foreach ($reflection_class->getMethods(\ReflectionMethod::IS_PUBLIC) as $method_reflection) {
foreach ($method_reflection->getAttributes(Hook::class, \ReflectionAttribute::IS_INSTANCEOF) as $attribute_reflection) {
$hook = $attribute_reflection->newInstance();
assert($hook instanceof Hook);
HookCollectorPass::checkForProceduralOnlyHooks($hook, static::class);
$map['hook_list'][$hook->hook][$this->definition
->getClass() . ':' . $method_reflection->getName()] = 'core';
}
}
$container->setParameter('.hook_data', $map);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.