You are here

public function CurrencyImportForm::submitForm in Currency 8.3

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/CurrencyImportForm.php, line 104

Class

CurrencyImportForm
Provides the currency import form.

Namespace

Drupal\currency\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $currency = $this->configImporter
    ->importCurrency($form_state
    ->getValues()['currency_code']);
  $this
    ->messenger()
    ->addMessage($this
    ->t('The %label has been imported.', [
    '%label' => $currency
      ->label(),
  ]));
  if ($form_state
    ->getTriggeringElement()['#name'] == 'import_edit') {
    $form_state
      ->setRedirectUrl($currency
      ->toUrl('edit-form'));
  }
  else {
    $form_state
      ->setRedirectUrl(new Url('entity.currency.collection'));
  }
}