You are here

public function UpdateHelper::writeStatus in Evercurrent 8.2

Same name and namespace in other branches
  1. 8 src/UpdateHelper.php \Drupal\evercurrent\UpdateHelper::writeStatus()

Saves a status message for the status page.

Parameters

string $severity: One of status or error.

string $message: The message you want to write.

bool $output: Should we output this meessage to the user.

3 calls to UpdateHelper::writeStatus()
UpdateHelper::sendUpdates in src/UpdateHelper.php
Send updates to the Maintenance server.
UpdateHelper::setKey in src/UpdateHelper.php
Check a key and set it if valid.
UpdateHelper::testUpdate in src/UpdateHelper.php
Test sending an update to the server.

File

src/UpdateHelper.php, line 231

Class

UpdateHelper
Default UpdateHelper instantiation.

Namespace

Drupal\evercurrent

Code

public function writeStatus($severity, $message, $output = FALSE) {
  $config = $this->configFactory
    ->getEditable('evercurrent.admin_config');
  $message = Xss::filter($message);
  $state = \Drupal::state();
  $state
    ->set('evercurrent_status_message', $message);
  $state
    ->set('evercurrent_status', $severity);
  $config
    ->save();

  // If error, also log to watchdog.
  if ($severity == RMH_STATUS_ERROR) {
    \Drupal::logger('evercurrent')
      ->error($message);
  }

  // Output this to message.
  if ($output) {
    $alert_type = $severity == RMH_STATUS_OK ? 'status' : 'error';
    $this->messenger
      ->addMessage($message, $alert_type);
  }
}