You are here

public function SiteAuditReportAbstract::toDrush in Site Audit 7

Same name and namespace in other branches
  1. 8.2 Report/Abstract.php \SiteAuditReportAbstract::toDrush()

Render response using Drush.

1 call to SiteAuditReportAbstract::toDrush()
SiteAuditReportAbstract::render in Report/Abstract.php
Render the report; respects drush options.

File

Report/Abstract.php, line 163
Contains \SiteAudit\Report\Abstract.

Class

SiteAuditReportAbstract
Class SiteAuditReportAbstract.

Code

public function toDrush() {
  if ($this->percent == SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_INFO) {
    drush_print(dt('!label: Info', array(
      '!label' => $this
        ->getLabel(),
    )));
  }
  else {
    drush_print(dt('!label: @percent%', array(
      '!label' => $this
        ->getLabel(),
      '@percent' => $this->percent,
    )));
  }
  if ($this->percent == 100) {
    drush_log(str_repeat(' ', 2) . dt('No action required.'), 'success');
  }
  if (drush_get_option('detail') || $this->percent != 100) {
    foreach ($this->checks as $check) {
      if (drush_get_option('detail') || $check
        ->getScore() != SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_PASS || $this->percent == SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_INFO) {
        if (drush_get_option('detail')) {
          drush_print(str_repeat(' ', 2) . dt('!label: !description', array(
            '!label' => $check
              ->getLabel(),
            '!description' => $check
              ->getDescription(),
          )));
        }
        else {
          if ($check
            ->getScore() != SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_INFO) {
            drush_print(str_repeat(' ', 2) . dt('!label', array(
              '!label' => $check
                ->getLabel(),
            )));
          }
        }
        if ($this->percent == SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_INFO || drush_get_option('detail')) {
          if ($check
            ->getScore() != SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_INFO || drush_get_option('detail')) {
            drush_print(str_repeat(' ', 4) . dt('!result', array(
              '!result' => $check
                ->getResult(),
            )));
          }
          else {
            drush_print(str_repeat(' ', 2) . dt('!result', array(
              '!result' => $check
                ->getResult(),
            )));
          }
        }
        else {
          drush_log(str_repeat(' ', 4) . dt('!result', array(
            '!result' => $check
              ->getResult(),
          )), $check
            ->getScoreDrushLevel());
        }
        if ($check
          ->renderAction()) {
          drush_print(str_repeat(' ', 6) . dt('!action', array(
            '!action' => $check
              ->renderAction(),
          )));
        }
      }
    }
  }
}