function ModuleHandler::invokeAllWith
Same name and namespace in other branches
- 10 core/lib/Drupal/Core/Extension/ModuleHandler.php \Drupal\Core\Extension\ModuleHandler::invokeAllWith()
- 11.x core/lib/Drupal/Core/Extension/ModuleHandler.php \Drupal\Core\Extension\ModuleHandler::invokeAllWith()
Executes a callback for each implementation of a hook.
The callback is passed two arguments, a closure which executes a hook implementation. And the module name.
Parameters
string $hook: The name of the hook to invoke.
callable $callback: A callable that invokes a hook implementation. Such that $callback is callable(callable, string): mixed. Arguments:
- Closure to a hook implementation.
- Implementation module machine name.
Overrides ModuleHandlerInterface::invokeAllWith
1 call to ModuleHandler::invokeAllWith()
- ModuleHandler::invokeAll in core/
lib/ Drupal/ Core/ Extension/ ModuleHandler.php - Invokes a hook in all enabled modules that implement it.
File
-
core/
lib/ Drupal/ Core/ Extension/ ModuleHandler.php, line 402
Class
- ModuleHandler
- Class that manages modules in a Drupal installation.
Namespace
Drupal\Core\ExtensionCode
public function invokeAllWith(string $hook, callable $callback) : void {
foreach (array_keys($this->getImplementationInfo($hook)) as $module) {
$hookInvoker = \Closure::fromCallable($module . '_' . $hook);
$callback($hookInvoker, $module);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.