You are here

protected static function SyncHealth::formatMessage in CMS Content Sync 2.1.x

Same name and namespace in other branches
  1. 8 modules/cms_content_sync_health/src/Controller/SyncHealth.php \Drupal\cms_content_sync_health\Controller\SyncHealth::formatMessage()
  2. 2.0.x modules/cms_content_sync_health/src/Controller/SyncHealth.php \Drupal\cms_content_sync_health\Controller\SyncHealth::formatMessage()

Formats a database log message.

Parameters

object $row: The record from the watchdog table. The object properties are: wid, uid, severity, type, timestamp, message, variables, link, name.

Return value

string|TranslatableMarkup|false The formatted log message or FALSE if the message or variables properties are not set.

File

modules/cms_content_sync_health/src/Controller/SyncHealth.php, line 127

Class

SyncHealth
Provides a listing of Flow.

Namespace

Drupal\cms_content_sync_health\Controller

Code

protected static function formatMessage($row) {

  // Check for required properties.
  if (isset($row->message, $row->variables)) {
    $variables = @unserialize($row->variables);

    // Messages without variables or user specified text.
    if ($variables === NULL) {
      $message = Xss::filterAdmin($row->message);
    }
    elseif (!is_array($variables)) {
      $message = t('Log data is corrupted and cannot be unserialized: @message', [
        '@message' => Xss::filterAdmin($row->message),
      ]);
    }
    else {
      $message = t(Xss::filterAdmin($row->message), $variables);
    }
  }
  else {
    $message = FALSE;
  }
  return $message;
}