public function BackupDatabaseForm::submitForm in Backup Database 8
Form submission handler.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Overrides FormInterface::submitForm
File
- src/
Form/ BackupDatabaseForm.php, line 70 - Contains \Drupal\backup_db\Form\BackupDatabaseForm.
Class
- BackupDatabaseForm
- BackupDatabaseForm class.
Namespace
Drupal\backup_db\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$values = $form_state
->getValues();
// Save filename.
\Drupal::configFactory()
->getEditable('backup_db.settings')
->set('filename', $values['filename'])
->save();
// Call backup_db client.
$client = \Drupal::service('backup_db.client');
// Select our adapter.
if ($values['type'] == 'download') {
$handler = new BackupDatabaseRemoteAdapter($client);
}
if ($values['type'] == 'local') {
$handler = new BackupDatabaseLocalAdapter($client);
}
// Run the export.
if ($handler
->export()) {
drupal_set_message(t('Backup has been successfully completed.'), 'status');
}
else {
drupal_set_message(t('Backup has failed, please review recent log messages.'), 'warning');
}
}