public function Console::render in Site Audit 8.3
Overrides Renderer::render
File
- src/
Renderer/ Console.php, line 124
Class
Namespace
Drupal\site_audit\RendererCode
public function render($detail = FALSE) {
$outputStyle = new OutputFormatterStyle('black', 'white');
$this->output
->getFormatter()
->setStyle('report', $outputStyle);
$outputStyle = new OutputFormatterStyle('black', 'cyan');
$this->output
->getFormatter()
->setStyle('check', $outputStyle);
$outputStyle = new OutputFormatterStyle('cyan', 'black');
$this->output
->getFormatter()
->setStyle('action', $outputStyle);
$outputStyle = new OutputFormatterStyle('green', 'black');
$this->output
->getFormatter()
->setStyle('success', $outputStyle);
$outputStyle = new OutputFormatterStyle('red', 'black');
$this->output
->getFormatter()
->setStyle('error', $outputStyle);
$outputStyle = new OutputFormatterStyle('yellow', 'black');
$this->output
->getFormatter()
->setStyle('warning', $outputStyle);
$outputStyle = new OutputFormatterStyle('cyan', 'black');
$this->output
->getFormatter()
->setStyle('note', $outputStyle);
$outputStyle = new OutputFormatterStyle('black', 'green');
$this->output
->getFormatter()
->setStyle('score-pass', $outputStyle);
$outputStyle = new OutputFormatterStyle('white', 'red');
$this->output
->getFormatter()
->setStyle('score-warn', $outputStyle);
$outputStyle = new OutputFormatterStyle('yellow', 'black');
$this->output
->getFormatter()
->setStyle('score-info', $outputStyle);
$reportText = '';
$percent = $this->report
->getPercent();
$style = $this
->getSymphonyStyle($percent);
// Add the report header.
$this
->horizontalRule();
$this
->centerText('<info>' . $this
->interpolate($this
->t('Report: ')) . $this
->interpolate($this->report
->getLabel()) . '</> - <' . $style . '>' . $percent . '%</>');
$this
->horizontalRule();
// No action required.
if ($percent == 100) {
$this
->centerText($this
->interpolate($this
->t('<success>No action required.</>')));
}
// Information or a problem.
if ($detail || $this->report
->getPercent() != 100) {
foreach ($this->report
->getCheckObjects() as $check) {
$label = $this->report
->getLabel() . ' - ' . $check
->getLabel();
$score = $check
->getScore();
if ($detail && $score == SiteAuditCheckBase::AUDIT_CHECK_SCORE_INFO || $score < SiteAuditCheckBase::AUDIT_CHECK_SCORE_PASS) {
// Heading.
$this->output
->writeln($this->formatter
->formatSection($label, $check
->getDescription()));
// Result.
$result = $check
->getResult();
$this->output
->writeln($this->formatter
->formatSection($label, $this
->interpolate($this
->t('Result: <@symfony-style>@logLevel</>', [
'@logLevel' => ucfirst(strtolower($this
->getLogLevel($score))),
'@symfony-style' => $this
->getScoreSymfonyStyle($score),
]))));
if (is_array($result)) {
if ($result['#theme'] && method_exists($this, $result['#theme'])) {
$this
->{$result['#theme']}($result, $label);
}
else {
if ($result['headers'] && $result['rows']) {
// Theme as a table.
$table = new Table($this->output);
$table
->setHeaders($result['headers'])
->setRows($result['rows']);
$this->output
->writeln($table
->render());
}
}
}
else {
$this->output
->writeln($this->formatter
->formatSection($label, $result));
}
// Action.
$action = $check
->renderAction();
if ($action) {
if (is_array($action) && $action['#theme'] && method_exists($this, $action['#theme'])) {
$this->output
->writeln($this->formatter
->formatSection($label, '<action>' . $this
->interpolate($this
->t('Action')) . ':</> ' . $action['#title']));
$this
->{$action['#theme']}($action, $label, 'action');
}
else {
$this->output
->writeln($this->formatter
->formatSection($label, '<action>' . $this
->interpolate($this
->t('Action')) . ':</> ' . $action));
}
}
}
$this->output
->writeln('');
}
}
$this->output
->writeln('<report>' . $reportText . '</>');
}