public function MigrationExecuteForm::submitForm in Migrate Tools 8.4
Same name and namespace in other branches
- 8.5 src/Form/MigrationExecuteForm.php \Drupal\migrate_tools\Form\MigrationExecuteForm::submitForm()
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/ MigrationExecuteForm.php, line 164
Class
- MigrationExecuteForm
- This form is specifically for configuring process pipelines.
Namespace
Drupal\migrate_tools\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$operation = $form_state
->getValue('operation');
if ($form_state
->getValue('limit')) {
$limit = $form_state
->getValue('limit');
}
else {
$limit = 0;
}
if ($form_state
->getValue('update')) {
$update = $form_state
->getValue('update');
}
else {
$update = 0;
}
if ($form_state
->getValue('force')) {
$force = $form_state
->getValue('force');
}
else {
$force = 0;
}
$migration = $this
->getRouteMatch()
->getParameter('migration');
if ($migration) {
/** @var \Drupal\migrate\Plugin\MigrationInterface $migration_plugin */
$migration_plugin = $this->migrationPluginManager
->createInstance($migration
->id(), $migration
->toArray());
$migrateMessage = new MigrateMessage();
switch ($operation) {
case 'import':
$options = [
'limit' => $limit,
'update' => $update,
'force' => $force,
];
$executable = new MigrateBatchExecutable($migration_plugin, $migrateMessage, $options);
$executable
->batchImport();
break;
case 'rollback':
$options = [
'limit' => $limit,
'update' => $update,
'force' => $force,
];
$executable = new MigrateBatchExecutable($migration_plugin, $migrateMessage, $options);
$executable
->rollback();
break;
case 'stop':
$migration_plugin
->interruptMigration(MigrationInterface::RESULT_STOPPED);
break;
case 'reset':
$migration_plugin
->setStatus(MigrationInterface::STATUS_IDLE);
break;
}
}
}