Skip to content
Snippets Groups Projects
Commit 7f8e21bf authored by Ronan Dowling's avatar Ronan Dowling
Browse files

Combine archive reader and writer

parent bf88f84e
No related branches found
No related tags found
No related merge requests found
......@@ -60,7 +60,7 @@ function backup_migrate_get_service_object($config_array = []) {
// Set the configuration overrides if any were passed in.
if ($config_array) {
$bam->setConfig(new \BackupMigrate\Core\Config\Config($config_array));
$bam->setConfig(new Config($config_array));
}
return $bam;
......@@ -88,6 +88,8 @@ function backup_migrate_backup_migrate_services_alter(\BackupMigrate\Core\Servic
new \BackupMigrate\Drupal\Environment\DrupalSetMessageLogger()
);
$services->add('ArchiveWriter', new \BackupMigrate\Core\Service\PearTarArchiver());
}
......@@ -106,11 +108,15 @@ function backup_migrate_backup_migrate_plugins_alter(\BackupMigrate\Core\Plugin\
if ($info['driver'] == 'mysql') {
$plugins->add(
'db',
new \BackupMigrate\Core\Source\MySQLiSource(
new \BackupMigrate\Core\Config\Config($info)
));
new \BackupMigrate\Core\Source\MySQLiSource(new Config($info)));
}
// Add the public files
$plugins->add(
'files_public',
new \BackupMigrate\Core\Source\FileDirectorySource(new Config(['directory' => 'public://']))
);
// Add a download destination.
$plugins->add('download', new \BackupMigrate\Drupal\Destination\DrupalBrowserDownloadDestination());
......@@ -143,3 +149,37 @@ function backup_migrate_backup_migrate_plugins_alter(\BackupMigrate\Core\Plugin\
}
/**
* @param \BackupMigrate\Core\Main\BackupMigrate $bam
* @return array
*/
function _backup_migrate_get_source_pulldown(\BackupMigrate\Core\Main\BackupMigrate $bam) {
$sources = $bam->plugins()->getAllByOp('exportToFile');
$source_ids = array();
foreach ($sources as $key => $source) {
$source_ids[$key] = $key;
}
return [
'#type' => 'select',
'#title' => t('Source'),
'#options' => $source_ids,
];
}
/**
* @param \BackupMigrate\Core\Main\BackupMigrate $bam
* @return array
*/
function _backup_migrate_get_destination_pulldown(\BackupMigrate\Core\Main\BackupMigrate $bam) {
$destinations = $bam->plugins()->getAllByOp('saveFile');
$destination_ids = array();
foreach ($destinations as $key => $destination) {
$destination_ids[$key] = $key;
}
return [
'#type' => 'select',
'#title' => t('Destination'),
'#options' => $destination_ids,
];
}
\ No newline at end of file
......@@ -44,6 +44,10 @@ class DrupalConfigHelper {
switch ($item['type']) {
case 'text':
$form_item['#type'] = 'textfield';
if (!empty($item['multiple'])) {
$form_item['#type'] = 'textarea';
$item['description'] .= t(' Add one item per line.');
}
break;
case 'password':
$form_item['#type'] = 'password';
......
......@@ -34,6 +34,11 @@ class BackupMigrateAdvancedBackupForm extends FormBase {
// @FIXME
// $form['#theme'] = 'backup_migrate_ui_manual_quick_backup_form_inline';
// $form['quickbackup']['destination'] = _backup_migrate_get_destination_pulldown('manual backup', \Drupal::config('backup_migrate.settings')->get('backup_migrate_destination_id'), \Drupal::config('backup_migrate.settings')->get('backup_migrate_copy_destination_id'));
$bam = backup_migrate_get_service_object();
$form['source'] = array(
'#type' => 'fieldset',
"#title" => t("Source"),
......@@ -41,13 +46,22 @@ class BackupMigrateAdvancedBackupForm extends FormBase {
"#collapsed" => FALSE,
"#tree" => FALSE,
);
$form['source']['source_id'] = _backup_migrate_get_source_pulldown($bam);
$form['source']['source_id']['#default_value'] = \Drupal::config('backup_migrate.settings')->get('backup_migrate_source_id');
$bam = backup_migrate_get_service_object();
$conf_schema = $bam->plugins()->map('configSchema', array('operation' => 'backup'));
$form += DrupalConfigHelper::buildFormFromSchema($conf_schema, $bam->plugins()->config());
// $form['quickbackup']['source_id'] = _backup_migrate_get_source_pulldown(\Drupal::config('backup_migrate.settings')->get('backup_migrate_source_id'));
// $form['quickbackup']['destination'] = _backup_migrate_get_destination_pulldown('manual backup', \Drupal::config('backup_migrate.settings')->get('backup_migrate_destination_id'), \Drupal::config('backup_migrate.settings')->get('backup_migrate_copy_destination_id'));
$form['destination'] = array(
'#type' => 'fieldset',
"#title" => t("Destination"),
"#collapsible" => TRUE,
"#collapsed" => FALSE,
"#tree" => FALSE,
);
$form['destination']['destination_id'] = _backup_migrate_get_destination_pulldown($bam);
$form['destination']['destination_id']['#default_value'] = \Drupal::config('backup_migrate.settings')->get('backup_migrate_destination_id');
$form['quickbackup']['submit'] = array(
'#type' => 'submit',
......@@ -81,7 +95,7 @@ class BackupMigrateAdvancedBackupForm extends FormBase {
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
$config = $form_state->getValues();
backup_migrate_perform_backup('db', 'download', $config);
backup_migrate_perform_backup($config['source_id'], 'download', $config);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment