BackupMigrateRestoreForm.php in Backup and Migrate 8.4
File
src/Form/BackupMigrateRestoreForm.php
View source
<?php
namespace Drupal\backup_migrate\Form;
use BackupMigrate\Drupal\Config\DrupalConfigHelper;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
class BackupMigrateRestoreForm extends FormBase {
public function getFormId() {
return 'backup_migrate_ui_manual_backup_quick';
}
public function buildForm(array $form, FormStateInterface $form_state) {
$form = [];
$bam = backup_migrate_get_service_object();
$form['backup_migrate_restore_upload'] = [
'#title' => $this
->t('Upload a Backup File'),
'#type' => 'file',
'#description' => $this
->t("Upload a backup file created by Backup\n and Migrate. For other database or file backups please use another\n tool for import. Max file size: %size", [
"%size" => format_size(file_upload_max_size()),
]),
];
$form['source_id'] = DrupalConfigHelper::getPluginSelector($bam
->sources(), $this
->t('Restore To'));
$form += DrupalConfigHelper::buildAllPluginsForm($bam
->plugins(), 'restore');
$form['quickbackup']['submit'] = [
'#type' => 'submit',
'#value' => $this
->t('Restore now'),
'#weight' => 1,
];
return $form;
}
public function validateForm(array &$form, FormStateInterface $form_state) {
parent::validateForm($form, $form_state);
}
public function submitForm(array &$form, FormStateInterface $form_state) {
$config = $form_state
->getValues();
backup_migrate_perform_restore($config['source_id'], 'upload', 'backup_migrate_restore_upload', $config);
}
}