You are here

protected function DebugForm::formatMessage in CMS Content Sync 8

Same name and namespace in other branches
  1. 2.1.x src/Form/DebugForm.php \Drupal\cms_content_sync\Form\DebugForm::formatMessage()
  2. 2.0.x src/Form/DebugForm.php \Drupal\cms_content_sync\Form\DebugForm::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

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

File

src/Form/DebugForm.php, line 418

Class

DebugForm
Content Sync advanced debug form.

Namespace

Drupal\cms_content_sync\Form

Code

protected 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 (null === $variables) {
      $message = Xss::filterAdmin($row->message);
    }
    elseif (!is_array($variables)) {
      $message = $this
        ->t('Log data is corrupted and cannot be unserialized: @message', [
        '@message' => Xss::filterAdmin($row->message),
      ]);
    }
    else {
      $message = $this
        ->t(Xss::filterAdmin($row->message), $variables);
    }
  }
  else {
    $message = false;
  }
  return $message;
}