You are here

public function DiagnosticsService::toMessageList in Purge 8.3

Generate a status_messages #message_list argument array.

Parameters

\Iterator $checks: Iterator yielding DiagnosticCheckInterface objects.

Return value

array[] Array with typed arrays, in each typed array are messages.

Overrides DiagnosticsServiceInterface::toMessageList

File

src/Plugin/Purge/DiagnosticCheck/DiagnosticsService.php, line 282

Class

DiagnosticsService
Provides a service that interacts with diagnostic checks.

Namespace

Drupal\purge\Plugin\Purge\DiagnosticCheck

Code

public function toMessageList(\Iterator $checks) {
  $messages = [];
  foreach ($checks as $check) {
    $type = strtolower($check
      ->getSeverityString());
    if (!isset($messages[$type])) {
      $messages[$type] = [];
    }
    $msg = strtoupper($check
      ->getTitle()) . ': ';
    if ($recommendation = $check
      ->getRecommendation()) {
      $msg .= ' ' . $recommendation;
    }
    $messages[$type][] = $msg;
  }
  return $messages;
}