- Issue created by @somatick
- Merge request !9Update file MigrateSourceUiForm.php to provide migrate_source_ui_batch_options_alter hook → (Open) created by somatick
We had a use case where a client wanted the sync option on their uploads, so that entries not present in the upload would be deleted.
In order to provide greater flexibility it seemed the best approach would be to allow the batch options sent to MigrateBatchExecutable to be an alterable array, so that other modules can provide additional options.
Provides a migrate_source_ui_batch_options_alter hook
An example usage would be to alter both the form and the batch options based on the new form field
/**
* Implements hook_form_FORM_ID_alter()
*/
function MODULE_form_migrate_source_ui_form_alter(&$form, $form_state) {
$form['sync_records'] = [
'#type' => 'checkbox',
'#title' => t('Sync records'),
'#default_value' => 0,
'#description' => t('Will delete previously migrated records that are not present in the current upload'),
'#weight' => 1,
];
$form['import']['#weight'] = 2;
}
/**
* Implements hook_migrate_source_ui_batch_options_alter()
*/
function MODULE_migrate_source_ui_batch_options_alter(&$options, $form, $form_state) {
// Sync records
if ($form_state->getValue('sync_records')) {
$options['sync'] = TRUE;
}
}
Active
1.1
Code