You are here

public function ContentLogController::formatMessage in Content Synchronization 8

Same name and namespace in other branches
  1. 8.2 src/Controller/ContentLogController.php \Drupal\content_sync\Controller\ContentLogController::formatMessage()
  2. 3.0.x src/Controller/ContentLogController.php \Drupal\content_sync\Controller\ContentLogController::formatMessage()

Formats a database log message.

Parameters

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

Return value

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

3 calls to ContentLogController::formatMessage()
ContentLogController::eventDetails in src/Controller/ContentLogController.php
Displays details about a specific database log message.
ContentLogController::overview in src/Controller/ContentLogController.php
Displays a listing of database log messages.
ContentLogController::topLogMessages in src/Controller/ContentLogController.php
Shows the most frequent log messages of a given event type.

File

src/Controller/ContentLogController.php, line 344

Class

ContentLogController
Returns responses for content_sync routes.

Namespace

Drupal\content_sync\Controller

Code

public 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 = $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;
}