You are here

public function ContentSingleImportForm::submitForm in Content Synchronization 8

Same name and namespace in other branches
  1. 8.2 src/Form/ContentSingleImportForm.php \Drupal\content_sync\Form\ContentSingleImportForm::submitForm()
  2. 3.0.x src/Form/ContentSingleImportForm.php \Drupal\content_sync\Form\ContentSingleImportForm::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/ContentSingleImportForm.php, line 60

Class

ContentSingleImportForm
Provides a form for importing a single content file.

Namespace

Drupal\content_sync\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $data = $form_state
    ->getValue('import');
  $operations = [];
  $operations[] = [
    'processContentBatch',
    [
      $data,
    ],
  ];
  $batch = [
    'operations' => $operations,
    'finished' => 'finishContentBatch',
    'title' => $this
      ->t('Importing content'),
    'init_message' => $this
      ->t('Starting content import.'),
    'progress_message' => $this
      ->t('Completed @current step of @total.'),
    'error_message' => $this
      ->t('Content import has encountered an error.'),
    'file' => drupal_get_path('module', 'content_sync') . '/content_sync.batch.inc',
  ];
  batch_set($batch);
}