You are here

function drush_acquia_purge_ap_diagnosis in Acquia Purge 6

Same name and namespace in other branches
  1. 7 acquia_purge.drush.inc \drush_acquia_purge_ap_diagnosis()

Perform a series of diagnostic self-tests.

File

./acquia_purge.drush.inc, line 84
Drush integration providing common maintenance tasks.

Code

function drush_acquia_purge_ap_diagnosis() {
  $oldverbosity = drush_get_context('DRUSH_VERBOSE');

  // Define a mapping between install.inc's requirement states and drush_log().
  $severitymap = array(
    ACQUIA_PURGE_SEVLEVEL_INFO => 'notice',
    ACQUIA_PURGE_SEVLEVEL_OK => 'ok',
    ACQUIA_PURGE_SEVLEVEL_WARNING => 'warning',
    ACQUIA_PURGE_SEVLEVEL_ERROR => 'error',
  );

  // Tell Drush to be verbose.
  drush_set_context('DRUSH_VERBOSE', TRUE);

  // Iterate the tests and call drush_log with the appropriate message type.
  foreach (_acquia_purge_get_diagnosis() as $test) {
    drush_log($test['value_plain'], $severitymap[$test['severity']]);
    if ($test['severity'] >= ACQUIA_PURGE_SEVLEVEL_WARNING) {
      printf("%s\n\n\n", $test['description_plain']);
    }
  }

  // Set back the old verbosity state.
  drush_set_context('DRUSH_VERBOSE', $oldverbosity);
}