public function Html::renderReport in Site Audit 8.3
Render a single report.
1 call to Html::renderReport()
- Html::render in src/
Renderer/ Html.php - Render either one report, or multiple.
File
- src/
Renderer/ Html.php, line 217
Class
Namespace
Drupal\site_audit\RendererCode
public function renderReport($report) {
$build = [];
// The report header.
$build['report_label'] = [
'#type' => 'html_tag',
'#tag' => 'h2',
'#value' => $report
->getLabel() . ' ',
'#attributes' => [
'id' => $report
->getPluginId(),
],
'percent' => [
'#type' => 'html_tag',
'#tag' => 'span',
'#value' => $report
->getPercent() . '%',
'#attributes' => [
'class' => 'label label-' . $this
->getPercentCssClass($report
->getPercent()),
],
],
];
$percent = $report
->getPercent();
if ($percent != SiteAuditCheckBase::AUDIT_CHECK_SCORE_INFO) {
// Show percent.
$build['report_label']['percent'] = [
'#type' => 'html_tag',
'#tag' => 'span',
'#value' => $percent . '%',
'#prefix' => ' ',
'#attributes' => [
'class' => 'label label-' . $this
->getPercentCssClass($percent),
],
];
}
else {
$build['label']['info'] = [
'#type' => 'html_tag',
'#tag' => 'span',
'#value' => $this
->t('Info'),
'#attributes' => [
'class' => 'label label-info',
],
];
}
if ($percent == 100) {
$build['success'] = [
'#type' => 'html_tag',
'#tag' => 'p',
'#value' => '<strong>' . $this
->t('Well done!') . '</strong> ' . $this
->t('No action required.'),
'#attributes' => [
'class' => 'text-success',
],
];
}
if ($this->options['detail'] || $percent != 100) {
foreach ($report
->getCheckObjects() as $check) {
$checkBuild = [];
$score = $check
->getScore();
if ($this->options['detail'] || $score < SiteAuditCheckBase::AUDIT_CHECK_SCORE_PASS || $percent == SiteAuditCheckBase::AUDIT_CHECK_SCORE_INFO) {
// Heading.
$checkBuild['panel']['panel_heading'] = [
'#type' => 'html_tag',
'#tag' => 'div',
'#value' => '<strong>' . $check
->getLabel() . '</strong>',
'#attributes' => [
'class' => 'panel-heading',
],
];
if ($this->options['detail']) {
$checkBuild['panel']['panel_heading']['description'] = [
'#type' => 'html_tag',
'#tag' => 'small',
'#value' => '- ' . $check
->getDescription(),
];
}
// Result.
$checkBuild['#result'] = $check
->getResult();
if (is_array($check
->getResult())) {
$checkBuild['result'] = $check
->getResult();
$checkBuild['result']['#attributes']['class'] = 'well result';
}
else {
$checkBuild['detail'] = [
'#type' => 'html_tag',
'#tag' => 'p',
'#value' => $check
->getResult(),
'#attributes' => [
'class' => 'well result',
],
];
}
// Action.
if ($action = $check
->renderAction()) {
$checkBuild['action'] = [
'#type' => 'html_tag',
'#tag' => 'div',
'#attributes' => [
'class' => 'well action',
],
];
if (!is_array($action)) {
$checkBuild['action']['text'] = [
'#type' => 'html_tag',
'#tag' => 'p',
'#value' => $action,
];
}
else {
$checkBuild['action']['rendered'] = $action;
}
}
$build[$check
->getPluginId()] = [
'#type' => 'html_tag',
'#tag' => 'div',
//'#value' => '<strong>' . $this->t('Well done!') . '</strong> ' . $this->t('No action required.'),
'#attributes' => [
'class' => 'panel panel-' . $this
->getScoreCssClass($check
->getScore()),
'id' => 'check-' . $check
->getPluginId(),
],
$checkBuild,
];
}
}
}
return $build;
}