function drupal_check_module in Drupal 10
Same name and namespace in other branches
- 8 core/includes/install.inc \drupal_check_module()
- 5 includes/install.inc \drupal_check_module()
- 6 includes/install.inc \drupal_check_module()
- 7 includes/install.inc \drupal_check_module()
- 9 core/includes/install.inc \drupal_check_module()
Checks a module's requirements.
Parameters
$module: Machine name of module to check.
Return value
TRUE or FALSE, depending on whether the requirements are met.
1 call to drupal_check_module()
- ModulesListForm::buildModuleList in core/
modules/ system/ src/ Form/ ModulesListForm.php - Helper function for building a list of modules to install.
File
- core/
includes/ install.inc, line 1035 - API functions for installing modules and themes.
Code
function drupal_check_module($module) {
/** @var \Drupal\Core\Extension\ModuleExtensionList $module_list */
$module_list = \Drupal::service('extension.list.module');
$file = DRUPAL_ROOT . '/' . $module_list
->getPath($module) . "/{$module}.install";
if (is_file($file)) {
require_once $file;
}
// Check requirements
$requirements = \Drupal::moduleHandler()
->invoke($module, 'requirements', [
'install',
]);
if (is_array($requirements) && drupal_requirements_severity($requirements) == REQUIREMENT_ERROR) {
// Print any error messages
foreach ($requirements as $requirement) {
if (isset($requirement['severity']) && $requirement['severity'] == REQUIREMENT_ERROR) {
$message = $requirement['description'];
if (isset($requirement['value']) && $requirement['value']) {
$message = t('@requirements_message (Currently using @item version @version)', [
'@requirements_message' => $requirement['description'],
'@item' => $requirement['title'],
'@version' => $requirement['value'],
]);
}
\Drupal::messenger()
->addError($message);
}
}
return FALSE;
}
return TRUE;
}