public function SiteAuditCommands::audit in Site Audit 8.3
Run a Site Audit report.
@option skip List of available reports. @option format Format you which the report is to be in (html, text, json, markdown) @option detail Show details when no issues found for the check. @option bootstrap Wrap the report in HTML with Bootstrap derived styles. Forces --format=html @usage site_audit:audit Run all Site Audit reports
@command site_audit:audit @aliases audit
@usage audit watchdog only run the watchdog report @usage audit --skip=block,status skip the block and status reports
Parameters
$report: The particular report to run. Omit this argument to choose from available reports.
1 call to SiteAuditCommands::audit()
- SiteAuditCommands::audit_all in src/
Commands/ SiteAuditCommands.php - Run All Site Audit reports.
File
- src/
Commands/ SiteAuditCommands.php, line 85
Class
- SiteAuditCommands
- SiteAudit Drush commandfile.
Namespace
Drupal\site_audit\CommandsCode
public function audit($report, $options = [
'skip' => 'none',
'format' => 'text',
'detail' => FALSE,
'bootstrap' => FALSE,
]) {
if ($options['bootstrap']) {
// Bootstrap implies html.
$options['format'] = 'html';
}
$boot_manager = Drush::bootstrapManager();
$output = $this
->output();
$out = '';
$reportDefinitions = $this->auditReportManager
->getDefinitions();
$reports = [];
if ($report == 'all') {
// Run all reports unless it is explicitly skipped.
$skipped = explode(',', $options['skip']);
foreach ($reportDefinitions as $report) {
$isSkipped = array_search($report['id'], $skipped);
if ($isSkipped === FALSE) {
$reports[] = $this->auditReportManager
->createInstance($report['id'], $options);
}
}
}
elseif (!empty($report)) {
$reports[] = $this->auditReportManager
->createInstance($report, $options);
}
switch ($options['format']) {
case 'html':
$renderer = new Html($reports, $this->logger, $options, $output);
$out .= $renderer
->render(TRUE);
break;
case 'json':
foreach ($reports as $report) {
$renderer = new Json($report, $this->logger, $options, $output);
$out .= $renderer
->render(TRUE);
}
break;
case 'markdown':
foreach ($reports as $report) {
$renderer = new Markdown($report, $this->logger, $options, $output);
$out .= $renderer
->render(TRUE);
}
break;
case 'text':
default:
foreach ($reports as $report) {
$renderer = new Console($report, $this->logger, $options, $output);
// The Console::renderer() doesn't return anything, it print directly to the console.
$renderer
->render(TRUE);
}
break;
}
return $out;
}