BackupDeleteForm.php in Backup and Migrate 5.0.x
File
src/Form/BackupDeleteForm.php
View source
<?php
namespace Drupal\backup_migrate\Form;
use Drupal\Core\Form\ConfirmFormBase;
use Drupal\Core\Form\FormStateInterface;
class BackupDeleteForm extends ConfirmFormBase {
public $destination;
public $backupId;
public function getQuestion() {
return $this
->t('Are you sure you want to delete this backup?');
}
public function getDescription() {
return $this
->t('This will permanently remove %backupId from %destination_name.', [
'%backupId' => $this->backupId,
'%destination_name' => $this->destination
->label(),
]);
}
public function getConfirmText() {
return $this
->t('Delete');
}
public function getCancelUrl() {
return $this->destination
->toUrl('backups');
}
public function getFormId() {
return 'backup_migrate_backup_delete_confirm';
}
public function buildForm(array $form, FormStateInterface $form_state, $backup_migrate_destination = NULL, $backup_id = NULL) {
$this->destination = $backup_migrate_destination;
$this->backupId = $backup_id;
return parent::buildForm($form, $form_state);
}
public function submitForm(array &$form, FormStateInterface $form_state) {
$destination = $this->destination
->getObject();
$destination
->deleteFile($this->backupId);
$form_state
->setRedirectUrl($this
->getCancelUrl());
}
}