You are here

public static function Modules::checkDisabled in Hook Update Deploy Tools 7

Same name and namespace in other branches
  1. 8 src/Modules.php \HookUpdateDeployTools\Modules::checkDisabled()

Check to see if modules are actually disabled.

Parameters

array $modules: An array of module machine names to check for being disabled.

Return value

string Messsage indicating the modules are disabled

Throws

\HudtException Calls the update a failure, preventing it from registering the update_N.

1 call to Modules::checkDisabled()
Modules::disable in src/Modules.php
Disables an array of modules and checks to make sure they were disabled.

File

src/Modules.php, line 21

Class

Modules
Public method for enabling modules that verifies it was actually enabled.

Namespace

HookUpdateDeployTools

Code

public static function checkDisabled($modules = array()) {
  $modules = (array) $modules;
  $enabled_modules = array();
  $t = get_t();
  $enabled = $t('enabled');
  $not_enabled = $t('disabled');
  $report = array();

  // Check to see if each module is disabled.
  foreach ($modules as $module) {
    if (module_exists($module)) {

      // This module is enabled.
      $report[$module] = $enabled;
    }
    else {
      $report[$module] = $not_enabled;
    }
  }
  if (in_array($enabled, $report)) {
    $message = 'The modules that were supposed to be disabled by this update, were not. Please investigate the problem and re-run this update. Report: !report';
    $variables = array(
      '!report' => $report,
    );
    throw new HudtException($message, $variables, WATCHDOG_ERROR, TRUE);
  }
  else {
    $message = "The requested modules are disabled. Report: !report";
    $variables = array(
      '!report' => $report,
    );
    return Message::make($message, $variables, WATCHDOG_INFO);
  }
}