function ModuleHandler::invoke
Same name in other branches
- 9 core/lib/Drupal/Core/Extension/ModuleHandler.php \Drupal\Core\Extension\ModuleHandler::invoke()
- 8.9.x core/lib/Drupal/Core/Extension/ModuleHandler.php \Drupal\Core\Extension\ModuleHandler::invoke()
- 10 core/lib/Drupal/Core/Extension/ModuleHandler.php \Drupal\Core\Extension\ModuleHandler::invoke()
Overrides ModuleHandlerInterface::invoke
1 call to ModuleHandler::invoke()
- ModuleHandler::invokeDeprecated in core/
lib/ Drupal/ Core/ Extension/ ModuleHandler.php - Invokes a deprecated hook in a particular module.
File
-
core/
lib/ Drupal/ Core/ Extension/ ModuleHandler.php, line 312
Class
- ModuleHandler
- Class that manages modules in a Drupal installation.
Namespace
Drupal\Core\ExtensionCode
public function invoke($module, $hook, array $args = []) {
if ($listeners = $this->getHookListeners($hook)[$module] ?? []) {
if (count($listeners) > 1) {
throw new \LogicException("Module {$module} should not implement {$hook} more than once");
}
return reset($listeners)(...$args);
}
return $this->legacyInvoke($module, $hook, $args);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.