class CircularDependencyHooks
Example to test that a hook service can depend on ModuleHandler.
This would cause a circular dependency problem, if the hook implementations in ModuleHandler were not lazy-loaded.
Hierarchy
- class \Drupal\hook_loader_test\Hook\CircularDependencyHooks
Expanded class hierarchy of CircularDependencyHooks
1 file declares its use of CircularDependencyHooks
- HookLoaderTest.php in core/
tests/ Drupal/ KernelTests/ Core/ Hook/ HookLoaderTest.php
File
-
core/
modules/ system/ tests/ modules/ HookLoader/ hook_loader_test/ src/ Hook/ CircularDependencyHooks.php, line 16
Namespace
Drupal\hook_loader_test\HookView source
class CircularDependencyHooks {
public function __construct(public readonly ModuleHandlerInterface $moduleHandler) {
}
public function testHook() : string {
// The hook method does not need to actually use the module handler.
// It is enough to require it in the constructor.
return __METHOD__;
}
}
Members
Title Sort descending | Modifiers | Object type | Summary |
---|---|---|---|
CircularDependencyHooks::testHook | public | function | #[Hook('test_hook')] |
CircularDependencyHooks::__construct | public | function |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.