function ModuleHandler::implementsHook

Same name in other branches
  1. 9 core/lib/Drupal/Core/Extension/ModuleHandler.php \Drupal\Core\Extension\ModuleHandler::implementsHook()

Overrides ModuleHandlerInterface::implementsHook

1 call to ModuleHandler::implementsHook()
ModuleHandler::invoke in core/lib/Drupal/Core/Extension/ModuleHandler.php
Invokes a hook in a particular module.

File

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

Class

ModuleHandler
Class that manages modules in a Drupal installation.

Namespace

Drupal\Core\Extension

Code

public function implementsHook($module, $hook) {
    $function = $module . '_' . $hook;
    if (function_exists($function)) {
        return TRUE;
    }
    // If the hook implementation does not exist, check whether it lives in an
    // optional include file registered via hook_hook_info().
    $hook_info = $this->getHookInfo();
    if (isset($hook_info[$hook]['group'])) {
        $this->loadInclude($module, 'inc', $module . '.' . $hook_info[$hook]['group']);
        if (function_exists($function)) {
            return TRUE;
        }
    }
    return FALSE;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.