function ModuleHandler::verifyImplementations
Same name in other branches
- 9 core/lib/Drupal/Core/Extension/ModuleHandler.php \Drupal\Core\Extension\ModuleHandler::verifyImplementations()
- 8.9.x core/lib/Drupal/Core/Extension/ModuleHandler.php \Drupal\Core\Extension\ModuleHandler::verifyImplementations()
Verifies an array of implementations loaded from cache.
Verification is done by including the lazy-loaded $module.$group.inc file, and checking function_exists().
Parameters
string[] $implementations: Implementation "group" by module name.
string $hook: The hook name.
Return value
bool TRUE, if all implementations exist. FALSE, if one or more implementations don't exist and need to be removed from the cache.
1 call to ModuleHandler::verifyImplementations()
- ModuleHandler::getImplementationInfo in core/
lib/ Drupal/ Core/ Extension/ ModuleHandler.php - Provides information about modules' implementations of a hook.
File
-
core/
lib/ Drupal/ Core/ Extension/ ModuleHandler.php, line 687
Class
- ModuleHandler
- Class that manages modules in a Drupal installation.
Namespace
Drupal\Core\ExtensionCode
protected function verifyImplementations(&$implementations, $hook) {
$all_valid = TRUE;
foreach ($implementations as $module => $group) {
// If this hook implementation is stored in a lazy-loaded file, include
// that file first.
if ($group) {
$this->loadInclude($module, 'inc', "{$module}.{$group}");
}
// It is possible that a module removed a hook implementation without
// the implementations cache being rebuilt yet, so we check whether the
// function exists on each request to avoid undefined function errors.
// Since ModuleHandler::implementsHook() may needlessly try to
// load the include file again, function_exists() is used directly here.
if (!function_exists($module . '_' . $hook)) {
// Clear out the stale implementation from the cache and force a cache
// refresh to forget about no longer existing hook implementations.
unset($implementations[$module]);
// One of the implementations did not exist and needs to be removed in
// the cache.
$all_valid = FALSE;
}
}
return $all_valid;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.