public function ChecklistController::results in Security Review 8
Creates the results' table.
Return value
array The render array for the result table.
1 call to ChecklistController::results()
- ChecklistController::index in src/
Controller/ ChecklistController.php - Creates the Run & Review page.
File
- src/
Controller/ ChecklistController.php, line 118
Class
- ChecklistController
- The class of the 'Run & Review' page's controller.
Namespace
Drupal\security_review\ControllerCode
public function results() {
// If there are no results return.
if ($this->securityReview
->getLastRun() <= 0) {
return [];
}
$checks = [];
foreach ($this->checklist
->getChecks() as $check) {
// Initialize with defaults.
$check_info = [
'message' => $this
->t('The check "@name" hasn\'t been run yet.', [
'@name' => $check
->getTitle(),
]),
'skipped' => $check
->isSkipped(),
];
// Get last result.
$last_result = $check
->lastResult();
if ($last_result != NULL) {
if (!$last_result
->isVisible()) {
continue;
}
$check_info['result'] = $last_result
->result();
$check_info['message'] = $last_result
->resultMessage();
}
// Determine help link.
$check_info['help_link'] = Link::createFromRoute('Details', 'security_review.help', [
'namespace' => $check
->getMachineNamespace(),
'title' => $check
->getMachineTitle(),
]);
// Add toggle button.
$toggle_text = $check
->isSkipped() ? 'Enable' : 'Skip';
$check_info['toggle_link'] = Link::createFromRoute($toggle_text, 'security_review.toggle', [
'check_id' => $check
->id(),
], [
'query' => [
'token' => $this->csrfToken
->get($check
->id()),
],
]);
// Add to array of completed checks.
$checks[] = $check_info;
}
return [
'#theme' => 'run_and_review',
'#date' => $this->securityReview
->getLastRun(),
'#checks' => $checks,
'#attached' => [
'library' => [
'security_review/run_and_review',
],
],
];
}