public function MigrateSourceUiForm::submitForm in Migrate source UI 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/ MigrateSourceUiForm.php, line 164
Class
- MigrateSourceUiForm
- Contribute form.
Namespace
Drupal\migrate_source_ui\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$migration_id = $form_state
->getValue('migrations');
/** @var \Drupal\migrate\Plugin\Migration $migration */
$migration = $this->pluginManagerMigration
->createInstance($migration_id);
// Reset status.
$status = $migration
->getStatus();
if ($status !== MigrationInterface::STATUS_IDLE) {
$migration
->setStatus(MigrationInterface::STATUS_IDLE);
$this
->messenger()
->addWarning($this
->t('Migration @id reset to Idle', [
'@id' => $migration_id,
]));
}
$options = [
'file_path' => $form_state
->getValue('file_path'),
];
// Force updates or not.
if ($form_state
->getValue('update_existing_records')) {
$options['update'] = TRUE;
}
$executable = new MigrateBatchExecutable($migration, new StubMigrationMessage(), $options);
$executable
->batchImport();
}