You are here

public function UpdateHelper::writeStatus in Evercurrent 8

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

Saves a status message for the status page.

Parameters

$severity:

$message:

$output:

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 210
Contains Drupal\evercurrent\UpdateHelper.

Class

UpdateHelper
Class UpdateHelper.

Namespace

Drupal\evercurrent

Code

public function writeStatus($severity, $message, $output = FALSE) {
  $config = $this->config_factory
    ->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';
    drupal_set_message($message, $alert_type);
  }
}