You are here

public function DashboardController::listAction in Devel 8

Same name and namespace in other branches
  1. 8.3 webprofiler/src/Controller/DashboardController.php \Drupal\webprofiler\Controller\DashboardController::listAction()
  2. 8.2 webprofiler/src/Controller/DashboardController.php \Drupal\webprofiler\Controller\DashboardController::listAction()
  3. 4.x webprofiler/src/Controller/DashboardController.php \Drupal\webprofiler\Controller\DashboardController::listAction()

Generates the list page.

Parameters

\Symfony\Component\HttpFoundation\Request $request:

Return value

array

1 string reference to 'DashboardController::listAction'
webprofiler.routing.yml in webprofiler/webprofiler.routing.yml
webprofiler/webprofiler.routing.yml

File

webprofiler/src/Controller/DashboardController.php, line 155

Class

DashboardController
Class DashboardController

Namespace

Drupal\webprofiler\Controller

Code

public function listAction(Request $request) {
  $limit = $request
    ->get('limit', 10);
  $this->profiler
    ->disable();
  $ip = $request->query
    ->get('ip');
  $method = $request->query
    ->get('method');
  $url = $request->query
    ->get('url');
  $profiles = $this->profiler
    ->find($ip, $url, $limit, $method, '', '');
  $rows = [];
  if (count($profiles)) {
    foreach ($profiles as $profile) {
      $row = [];
      $row[] = $this
        ->l($profile['token'], new Url('webprofiler.dashboard', [
        'profile' => $profile['token'],
      ]));
      $row[] = $profile['ip'];
      $row[] = $profile['method'];
      $row[] = $profile['url'];
      $row[] = $this->date
        ->format($profile['time']);
      $rows[] = $row;
    }
  }
  else {
    $rows[] = [
      [
        'data' => $this
          ->t('No profiles found'),
        'colspan' => 6,
      ],
    ];
  }
  $build = [];
  $storage_id = $this
    ->config('webprofiler.config')
    ->get('storage');
  $storage = $this->storageManager
    ->getStorage($storage_id);
  $build['resume'] = [
    '#type' => 'inline_template',
    '#template' => '<p>{{ message }}</p>',
    '#context' => [
      'message' => $this
        ->t('Profiles stored with %storage service.', [
        '%storage' => $storage['title'],
      ]),
    ],
  ];
  $build['filters'] = $this
    ->formBuilder()
    ->getForm('Drupal\\webprofiler\\Form\\ProfilesFilterForm');
  $build['table'] = [
    '#type' => 'table',
    '#rows' => $rows,
    '#header' => [
      $this
        ->t('Token'),
      [
        'data' => $this
          ->t('Ip'),
        'class' => [
          RESPONSIVE_PRIORITY_LOW,
        ],
      ],
      [
        'data' => $this
          ->t('Method'),
        'class' => [
          RESPONSIVE_PRIORITY_LOW,
        ],
      ],
      $this
        ->t('Url'),
      [
        'data' => $this
          ->t('Time'),
        'class' => [
          RESPONSIVE_PRIORITY_MEDIUM,
        ],
      ],
    ],
    '#sticky' => TRUE,
  ];
  return $build;
}