public function DefaultController::backgroundProcessOverviewPage in Background Process 8
Implements Background Process Overview Page.
1 string reference to 'DefaultController::backgroundProcessOverviewPage'
File
- src/
Controller/ DefaultController.php, line 114
Class
- DefaultController
- Implements Default controller for the background_process module.
Namespace
Drupal\background_process\ControllerCode
public function backgroundProcessOverviewPage() {
$processes = background_process_get_processes();
$data = [];
global $base_url;
foreach ($processes as $process) {
$progress = progress_get_progress($process->handle);
$url = Url::fromUri($base_url . '/background-process/unlock/' . rawurlencode($process->handle));
$external_link = \Drupal::l($this
->t('Unlock'), $url);
if ($process->callback[1] != '') {
$process->callback = $process->callback[1];
}
$data[] = [
$process->handle,
_background_process_callback_name($process->callback),
$process->uid,
$process->service_host,
\Drupal::service('date.formatter')
->format((int) $process->start, 'custom', 'Y-m-d H:i:s'),
$progress ? sprintf("%.02f%%", $progress->progress * 100) : $this
->t('N/A'),
$external_link,
[
'attributes' => [
'class' => 'button-unlock',
],
'query' => \Drupal::service('redirect.destination')
->getAsArray(),
],
];
}
$header = [
'Handle',
'Callback',
'User',
'Host',
'Start time',
'Progress',
'Unlock',
];
// The table description.
$markup = [
'#type' => 'table',
'#header' => $header,
'#rows' => $data,
];
return $markup;
}