You are here

public function CSVIntroductionForm::submitForm in Commerce Smart Importer 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/CSVIntroductionForm.php, line 163

Class

CSVIntroductionForm
Introduction form.

Namespace

Drupal\commerce_smart_importer\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $triggering_element = $form_state
    ->getTriggeringElement()['#value']
    ->getUntranslatedString();
  if ($triggering_element == 'I have CSV file for import') {
    $http = [
      'action' => 'check',
    ];
    $form_state
      ->setRedirect('commerce_smart_importer.csv_importer', $http);
  }
  elseif ($triggering_element == 'I have CSV file for update') {
    $http = [
      'action' => 'check',
    ];
    $form_state
      ->setRedirect('commerce_smart_importer.csv_updater', $http);
  }
  elseif ($triggering_element == 'Export products') {
    $form_state
      ->setRedirect('commerce_smart_importer.exporter');
  }
  else {
    $form_state
      ->setRedirect('commerce_smart_importer.configure_smart_importer');
  }
}