You are here

function _security_review_drush_format_result in Security Review 7

Same name and namespace in other branches
  1. 6 security_review.drush.inc \_security_review_drush_format_result()

Helper function to format Security Review results.

Parameters

array $check: Check array with keys 'title', 'success', 'failure', 'result'

boolean $short_titles: Whether to use short message (check title) or full check success or failure message.

boolean $show_results: Whether to print failed check results.

Return value

array|NULL An array with the security review check's result, or NULL if no result.

1 call to _security_review_drush_format_result()
security_review_drush in ./security_review.drush.inc
Run checklist and display results command.

File

./security_review.drush.inc, line 205
Drush commands for Security Review module.

Code

function _security_review_drush_format_result($check, $short_titles = FALSE, $show_results = FALSE) {
  if (is_null($check['result'])) {

    // Do nothing if result is NULL.
    return;
  }
  elseif ($check['result']) {
    $element = $short_titles ? 'title' : 'success';
    $message = $check[$element];
    $status = 'success';
    $findings = $check['value'];
  }
  else {
    $element = $short_titles ? 'title' : 'failure';
    $message = $check[$element];
    $findings = $check['value'];
    if ($show_results && !empty($findings)) {
      $message .= "\n";
      foreach (_security_review_drush_findings_output($check) as $item) {
        $message .= "\t" . $item . "\n";
      }
    }
    $status = 'error';
  }
  return array(
    'message' => $message,
    'status' => $status,
    'findings' => $findings,
  );
}