function HookCollectorPass::checkForProceduralOnlyHooks
Checks for hooks which can't be supported in classes.
Parameters
\Drupal\Core\Hook\Attribute\Hook $hookAttribute: The hook to check.
class-string $class: The class the hook is implemented on.
1 call to HookCollectorPass::checkForProceduralOnlyHooks()
- HookCollectorPass::collectModuleHookImplementations in core/
lib/ Drupal/ Core/ Hook/ HookCollectorPass.php - Collects procedural and Attribute hook implementations.
File
-
core/
lib/ Drupal/ Core/ Hook/ HookCollectorPass.php, line 576
Class
- HookCollectorPass
- Collects and registers hook implementations.
Namespace
Drupal\Core\HookCode
public static function checkForProceduralOnlyHooks(Hook $hookAttribute, string $class) : void {
$staticDenyHooks = [
'hook_info',
'install',
'module_implements_alter',
'requirements',
'schema',
'uninstall',
'update_last_removed',
'install_tasks',
'install_tasks_alter',
];
if (in_array($hookAttribute->hook, $staticDenyHooks) || preg_match('/^(post_update_|update_\\d+$)/', $hookAttribute->hook)) {
throw new \LogicException("The hook {$hookAttribute->hook} on class {$class} does not support attributes and must remain procedural.");
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.