W3cubDocs

/Drupal 8

public function ModuleHandler::invoke

public ModuleHandler::invoke($module, $hook, array $args = array())

Invokes a hook in a particular module.

Parameters

string $module: The name of the module (without the .module extension).

string $hook: The name of the hook to invoke.

array $args: Arguments to pass to the hook implementation.

Return value

mixed The return value of the hook implementation.

Overrides ModuleHandlerInterface::invoke

File

core/lib/Drupal/Core/Extension/ModuleHandler.php, line 386

Class

ModuleHandler
Class that manages modules in a Drupal installation.

Namespace

Drupal\Core\Extension

Code

public function invoke($module, $hook, array $args = array()) {
  if (!$this->implementsHook($module, $hook)) {
    return;
  }
  $function = $module . '_' . $hook;
  return call_user_func_array($function, $args);
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Extension!ModuleHandler.php/function/ModuleHandler::invoke/8.1.x