public function BackupController::listDestinationBackups in Backup and Migrate 8.4
Same name and namespace in other branches
- 5.0.x src/Controller/BackupController.php \Drupal\backup_migrate\Controller\BackupController::listDestinationBackups()
List the backups in the given destination.
Parameters
\BackupMigrate\Core\Destination\ListableDestinationInterface $destination:
Return value
mixed
1 call to BackupController::listDestinationBackups()
- BackupController::listDestinationEntityBackups in src/
Controller/ BackupController.php - List the backups in the given destination.
File
- src/
Controller/ BackupController.php, line 86
Class
- BackupController
- Class BackupController.
Namespace
Drupal\backup_migrate\ControllerCode
public function listDestinationBackups(ListableDestinationInterface $destination, $backup_migrate_destination_id, $count = NULL) {
// Get a sorted list of files.
$rows = [];
$header = [
[
'data' => $this
->t('Name'),
'class' => [
RESPONSIVE_PRIORITY_MEDIUM,
],
'field' => 'name',
],
[
'data' => $this
->t('Date'),
'class' => [
RESPONSIVE_PRIORITY_MEDIUM,
],
'field' => 'datestamp',
'sort' => 'desc',
],
[
'data' => $this
->t('Size'),
'class' => [
RESPONSIVE_PRIORITY_MEDIUM,
],
'field' => 'filesize',
'sort' => 'desc',
],
[
'data' => $this
->t('Operations'),
'class' => [
RESPONSIVE_PRIORITY_LOW,
],
],
];
$order = tablesort_get_order($header);
$sort = tablesort_get_sort($header);
$php_sort = $sort == 'desc' ? SORT_DESC : SORT_ASC;
$backups = $destination
->queryFiles([], $order['sql'], $php_sort, $count);
foreach ($backups as $backup_id => $backup) {
$rows[] = [
'data' => [
// Cells.
$backup
->getFullName(),
\Drupal::service('date.formatter')
->format($backup
->getMeta('datestamp')),
format_size($backup
->getMeta('filesize')),
[
'data' => [
'#type' => 'operations',
'#links' => [
'restore' => [
'title' => $this
->t('Restore'),
'url' => Url::fromRoute('entity.backup_migrate_destination.backup_restore', [
'backup_migrate_destination' => $backup_migrate_destination_id,
'backup_id' => $backup_id,
]),
],
'download' => [
'title' => $this
->t('Download'),
'url' => Url::fromRoute('entity.backup_migrate_destination.backup_download', [
'backup_migrate_destination' => $backup_migrate_destination_id,
'backup_id' => $backup_id,
]),
],
'delete' => [
'title' => $this
->t('Delete'),
'url' => Url::fromRoute('entity.backup_migrate_destination.backup_delete', [
'backup_migrate_destination' => $backup_migrate_destination_id,
'backup_id' => $backup_id,
]),
],
],
],
],
],
];
}
$build['backups_table'] = [
'#type' => 'table',
'#header' => $header,
'#rows' => $rows,
'#empty' => $this
->t('There are no backups in this destination.'),
];
return $build;
}