You are here

public function PluginBasedExchangeRateProviderForm::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/PluginBasedExchangeRateProviderForm.php, line 131

Class

PluginBasedExchangeRateProviderForm
Provides the configuration form for \Drupal\currency\PluginBasedExchangeRateProvider.

Namespace

Drupal\currency\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $values = $form_state
    ->getValues();
  uasort($values['exchange_rate_providers'], [
    SortArray::class,
    'sortByWeightElement',
  ]);
  $configuration = array();
  foreach ($values['exchange_rate_providers'] as $plugin_id => $exchanger_configuration) {
    $configuration[$plugin_id] = (bool) $exchanger_configuration['enabled'];
  }
  $this->exchangeRateProvider
    ->saveConfiguration($configuration);
  $this
    ->messenger()
    ->addMessage($this
    ->t('The configuration options have been saved.'));
}