You are here

public function WebformSubmissionExportImportUploadForm::submitImportForm in Webform 6.x

Same name and namespace in other branches
  1. 8.5 modules/webform_submission_export_import/src/Form/WebformSubmissionExportImportUploadForm.php \Drupal\webform_submission_export_import\Form\WebformSubmissionExportImportUploadForm::submitImportForm()

Import 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.

File

modules/webform_submission_export_import/src/Form/WebformSubmissionExportImportUploadForm.php, line 432

Class

WebformSubmissionExportImportUploadForm
Upload webform submission export import CSV.

Namespace

Drupal\webform_submission_export_import\Form

Code

public function submitImportForm(array &$form, FormStateInterface $form_state) {
  $this
    ->setImportUri($form_state);
  $webform = $this->requestHandler
    ->getCurrentWebform();
  $source_entity = $this->requestHandler
    ->getCurrentSourceEntity();
  $import_uri = $this->importer
    ->getImportUri();
  $import_options = $form_state
    ->getValue('import_options');
  $redirect_url = $this->requestHandler
    ->getCurrentWebformUrl('webform.results_submissions');
  $form_state
    ->setRedirectUrl($redirect_url);
  if ($this->importer
    ->requiresBatch()) {
    static::batchSet($webform, $source_entity, $import_uri, $import_options);
  }
  else {
    $this->importer
      ->setImportOptions($import_options);
    $stats = $this->importer
      ->import();
    static::displayStats($stats);
    $this->importer
      ->deleteImportUri();
  }
}