You are here

public function XHProfController::runsAction in XHProf 8

Returns list of runs.

Return value

array A render array.

1 string reference to 'XHProfController::runsAction'
xhprof.routing.yml in ./xhprof.routing.yml
xhprof.routing.yml

File

src/Controller/XHProfController.php, line 59

Class

XHProfController
Displays profiling results.

Namespace

Drupal\xhprof\Controller

Code

public function runsAction() {
  $runs = $run = $this->profiler
    ->getStorage()
    ->getRuns();
  $rows = [];
  foreach ($runs as $run) {
    $rows[] = [
      Link::createFromRoute($run['run_id'], 'xhprof.run', [
        'run' => $run['run_id'],
      ]),
      format_size($run['size']),
      isset($run['path']) ? $run['path'] : '',
      $this->dateFormatter
        ->format($run['date'], 'small'),
    ];
  }
  return [
    'table' => [
      '#type' => 'table',
      '#header' => [
        [
          'data' => $this
            ->t('View'),
        ],
        [
          'data' => $this
            ->t('File size'),
        ],
        [
          'data' => $this
            ->t('Path'),
          'field' => 'path',
        ],
        [
          'data' => $this
            ->t('Date'),
          'field' => 'date',
          'sort' => 'desc',
        ],
      ],
      '#rows' => $rows,
      '#empty' => $this
        ->t('No runs collected'),
      '#attributes' => [
        'id' => 'xhprof-runs-table',
      ],
    ],
  ];
}