public function XHProfController::runAction in XHProf 8
Renders the run.
Parameters
\Drupal\xhprof\XHProfLib\Run $run: The run.
\Symfony\Component\HttpFoundation\Request $request: The request.
Return value
array A render array.
1 string reference to 'XHProfController::runAction'
File
- src/
Controller/ XHProfController.php, line 99
Class
- XHProfController
- Displays profiling results.
Namespace
Drupal\xhprof\ControllerCode
public function runAction(Run $run, Request $request) {
$length = $request->query
->get('length', 100);
$sort = $request->query
->get('sort', 'wt');
$report = $this->reportEngine
->getReport(NULL, NULL, $run, NULL, NULL, $sort, NULL, NULL);
$run_id = $run
->getId();
$build['#title'] = $this
->t('XHProf view report for %id', [
'%id' => $run_id,
]);
$descriptions = ReportConstants::getDescriptions();
$build['summary'] = [
'table' => [
'#type' => 'table',
'#responsive' => FALSE,
'#header' => [
$this
->t('Overall summary'),
$this
->t('%mu is <a href=":wiki">microseconds</a>', [
'%mu' => 'μs',
':wiki' => 'https://en.wikipedia.org/wiki/Microsecond',
]),
],
'#rows' => $this
->getSummaryRows($report, $descriptions),
],
];
$build['length'] = [
'#type' => 'inline_template',
'#template' => $length == -1 ? '<h3>Displaying all functions, sorted by {{ sort }}. [{{ top }}]</h3>' : '<h3>Displaying top {{ length }} functions, sorted by {{ sort }}. [{{ all }}]</h3>',
'#context' => [
'length' => $length,
'all' => Link::createFromRoute($this
->t('show all'), 'xhprof.run', [
'run' => $run_id,
'length' => -1,
]),
'top' => Link::createFromRoute($this
->t('show top'), 'xhprof.run', [
'run' => $run_id,
'length' => 100,
]),
'sort' => Xss::filter($descriptions[$sort], []),
],
];
$build['table'] = [
'#type' => 'table',
'#responsive' => FALSE,
'#sticky' => TRUE,
'#header' => $this
->getRunHeader($report, $descriptions, $run_id),
'#rows' => $this
->getRunRows($run, $report, $length),
'#attributes' => [
'class' => [
'responsive',
],
],
'#attached' => [
'library' => [
'xhprof/xhprof',
],
],
'#cache' => [
'contexts' => [
'url.query_args',
],
],
];
return $build;
}