You are here

public function AdminReadinessMessages::displayAdminPageMessages in Automatic Updates 8.2

Displays the checker results messages on admin pages.

File

src/Validation/AdminReadinessMessages.php, line 102

Class

AdminReadinessMessages
Class for displaying readiness messages on admin pages.

Namespace

Drupal\automatic_updates\Validation

Code

public function displayAdminPageMessages() : void {
  if (!$this
    ->displayResultsOnCurrentPage()) {
    return;
  }
  if ($this->readinessCheckerManager
    ->getResults() === NULL) {
    $checker_url = Url::fromRoute('automatic_updates.update_readiness')
      ->setOption('query', $this
      ->getDestinationArray());
    if ($checker_url
      ->access()) {
      $this
        ->messenger()
        ->addError($this
        ->t('Your site has not recently run an update readiness check. <a href=":url">Run readiness checks now.</a>', [
        ':url' => $checker_url
          ->toString(),
      ]));
    }
  }
  else {

    // Display errors, if there are any. If there aren't, then display
    // warnings, if there are any.
    if (!$this
      ->displayResultsForSeverity(SystemManager::REQUIREMENT_ERROR)) {
      $this
        ->displayResultsForSeverity(SystemManager::REQUIREMENT_WARNING);
    }
  }
}