function ModuleHandler::getImplementationInfo

Same name in other branches
  1. 9 core/lib/Drupal/Core/Extension/ModuleHandler.php \Drupal\Core\Extension\ModuleHandler::getImplementationInfo()
  2. 8.9.x core/lib/Drupal/Core/Extension/ModuleHandler.php \Drupal\Core\Extension\ModuleHandler::getImplementationInfo()
  3. 10 core/lib/Drupal/Core/Extension/ModuleHandler.php \Drupal\Core\Extension\ModuleHandler::getImplementationInfo()

Provides information about modules' implementations of a hook.

Parameters

string $hook: The name of the hook (e.g. "help" or "menu").

Return value

mixed[] An array whose keys are the names of the modules which are implementing this hook and whose values are either a string identifying a file in which the implementation is to be found, or FALSE, if the implementation is in the module file.

4 calls to ModuleHandler::getImplementationInfo()
ModuleHandler::alter in core/lib/Drupal/Core/Extension/ModuleHandler.php
Passes alterable variables to specific hook_TYPE_alter() implementations.
ModuleHandler::hasImplementations in core/lib/Drupal/Core/Extension/ModuleHandler.php
Determines whether there are implementations of a hook.
ModuleHandler::invokeAllWith in core/lib/Drupal/Core/Extension/ModuleHandler.php
Executes a callback for each implementation of a hook.
ModuleHandler::triggerDeprecationError in core/lib/Drupal/Core/Extension/ModuleHandler.php
Triggers an E_USER_DEPRECATED error if any module implements the hook.

File

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

Class

ModuleHandler
Class that manages modules in a Drupal installation.

Namespace

Drupal\Core\Extension

Code

protected function getImplementationInfo($hook) {
    if (!isset($this->implementations)) {
        $this->implementations = [];
        $this->verified = [];
        if ($cache = $this->cacheBackend
            ->get('module_implements')) {
            $this->implementations = $cache->data;
        }
    }
    if (!isset($this->implementations[$hook])) {
        // The hook is not cached, so ensure that whether or not it has
        // implementations, the cache is updated at the end of the request.
        $this->cacheNeedsWriting = TRUE;
        // Discover implementations.
        $this->implementations[$hook] = $this->buildImplementationInfo($hook);
        // Implementations are always "verified" as part of the discovery.
        $this->verified[$hook] = TRUE;
    }
    elseif (!isset($this->verified[$hook])) {
        if (!$this->verifyImplementations($this->implementations[$hook], $hook)) {
            // One or more of the implementations did not exist and need to be
            // removed in the cache.
            $this->cacheNeedsWriting = TRUE;
        }
        $this->verified[$hook] = TRUE;
    }
    return $this->implementations[$hook];
}

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