You are here

public function DevelDebugLogController::listLogs in Devel Debug Log 8

Lists debug information.

Return value

array Renderable array that contains a list of debug data.

1 string reference to 'DevelDebugLogController::listLogs'
devel_debug_log.routing.yml in ./devel_debug_log.routing.yml
devel_debug_log.routing.yml

File

src/Controller/DevelDebugLogController.php, line 75

Class

DevelDebugLogController

Namespace

Drupal\devel_debug_log\Controller

Code

public function listLogs() {
  $query = $this->database
    ->select('devel_debug_log', 'm')
    ->extend('Drupal\\Core\\Database\\Query\\PagerSelectExtender');
  $results = $query
    ->fields('m', [
    'timestamp',
    'title',
    'message',
  ])
    ->orderBy('id', 'desc')
    ->execute();
  $rows = [];
  foreach ($results as $result) {
    $rows[] = array(
      'title' => $result->title,
      'time' => $this->dateFormatter
        ->format($result->timestamp, 'short'),
      'message' => $result->message,
    );
  }
  if (empty($rows)) {
    return array(
      '#markup' => $this
        ->t('No debug messages.'),
    );
  }
  $build = array(
    'messages' => array(
      '#theme' => 'devel_debug_log_list',
      '#content' => $rows,
      '#delete_form' => $this->formBuilder
        ->getForm('Drupal\\devel_debug_log\\Form\\DevelDebugLogDeleteForm'),
    ),
    'pager' => array(
      '#type' => 'pager',
    ),
  );
  return $build;
}