DbLogController::eventDetails

public DbLogController::eventDetails($event_id)

Displays details about a specific database log message.

Parameters

int $event_id: Unique ID of the database log message.

Return value

array If the ID is located in the Database Logging table, a build array in the format expected by drupal_render();

File

core/modules/dblog/src/Controller/DbLogController.php, line 238

Class

DbLogController
Returns responses for dblog routes.

Namespace

Drupal\dblog\Controller

Code

public function eventDetails($event_id) {
  $build = array();
  if ($dblog = $this->database->query('SELECT w.*, u.uid FROM {watchdog} w LEFT JOIN {users} u ON u.uid = w.uid WHERE w.wid = :id', array(':id' => $event_id))->fetchObject()) {
    $severity = RfcLogLevel::getLevels();
    $message = $this->formatMessage($dblog);
    $username = array(
      '#theme' => 'username',
      '#account' => $dblog->uid ? $this->userStorage->load($dblog->uid) : User::getAnonymousUser(),
    );
    $rows = array(
      array(
        array('data' => $this->t('Type'), 'header' => TRUE),
        $this->t($dblog->type),
      ),
      array(
        array('data' => $this->t('Date'), 'header' => TRUE),
        $this->dateFormatter->format($dblog->timestamp, 'long'),
      ),
      array(
        array('data' => $this->t('User'), 'header' => TRUE),
        array('data' => $username),
      ),
      array(
        array('data' => $this->t('Location'), 'header' => TRUE),
        $this->l($dblog->location, $dblog->location ? Url::fromUri($dblog->location) : Url::fromRoute('<none>')),
      ),
      array(
        array('data' => $this->t('Referrer'), 'header' => TRUE),
        $this->l($dblog->referer, $dblog->referer ? Url::fromUri($dblog->referer) : Url::fromRoute('<none>')),
      ),
      array(
        array('data' => $this->t('Message'), 'header' => TRUE),
        $message,
      ),
      array(
        array('data' => $this->t('Severity'), 'header' => TRUE),
        $severity[$dblog->severity],
      ),
      array(
        array('data' => $this->t('Hostname'), 'header' => TRUE),
        $dblog->hostname,
      ),
      array(
        array('data' => $this->t('Operations'), 'header' => TRUE),
        array('data' => array('#markup' => $dblog->link)),
      ),
    );
    $build['dblog_table'] = array(
      '#type' => 'table',
      '#rows' => $rows,
      '#attributes' => array('class' => array('dblog-event')),
      '#attached' => array(
        'library' => array('dblog/drupal.dblog'),
      ),
    );
  }

  return $build;
}
doc_Drupal
2016-10-29 09:01:15
Comments
Leave a Comment

Please login to continue.