drupal_check_module

drupal_check_module($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.

File

core/includes/install.inc, line 994
API functions for installing modules and themes.

Code

function drupal_check_module($module) {
  module_load_install($module);
  // Check requirements
  $requirements = \Drupal::moduleHandler()->invoke($module, 'requirements', array('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)', array('@requirements_message' => $requirement['description'], '@item' => $requirement['title'], '@version' => $requirement['value']));
        }
        drupal_set_message($message, 'error');
      }
    }
    return FALSE;
  }
  return TRUE;
}
doc_Drupal
2016-10-29 09:03:10
Comments
Leave a Comment

Please login to continue.