You are here

public function BackupController::listAll in Backup and Migrate 8.4

Same name and namespace in other branches
  1. 5.0.x src/Controller/BackupController.php \Drupal\backup_migrate\Controller\BackupController::listAll()
1 string reference to 'BackupController::listAll'
backup_migrate.routing.yml in ./backup_migrate.routing.yml
backup_migrate.routing.yml

File

src/Controller/BackupController.php, line 27

Class

BackupController
Class BackupController.

Namespace

Drupal\backup_migrate\Controller

Code

public function listAll() {
  $storage = \Drupal::entityTypeManager()
    ->getStorage('backup_migrate_destination');
  $out = [];
  foreach ($storage
    ->getQuery()
    ->execute() as $key) {
    $entity = $storage
      ->load($key);
    $destination = $entity
      ->getObject();
    $label = $destination
      ->confGet('name');
    $out[$key] = [
      'title' => [
        '#markup' => '<h2>' . $this
          ->t('Most recent backups in %dest', [
          '%dest' => $label,
        ]) . '</h2>',
      ],
      'list' => $this::listDestinationBackups($destination, $key, 5),
    ];

    // Add the more link.
    if ($entity
      ->access('backups') && $entity
      ->hasLinkTemplate('backups')) {
      $out[$key]['link'] = $entity
        ->toLink($this
        ->t('View all backups in %dest', [
        '%dest' => $label,
      ]), 'backups')
        ->toRenderable();
    }
  }
  return $out;
}