You are here

public function MailchimpEcommerceAdminSettings::submitForm in Mailchimp E-Commerce 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 ConfigFormBase::submitForm

File

src/Form/MailchimpEcommerceAdminSettings.php, line 62

Class

MailchimpEcommerceAdminSettings

Namespace

Drupal\mailchimp_ecommerce\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $config = $this
    ->config('mailchimp_ecommerce.settings');
  $settings = [
    'mailchimp_ecommerce_store_name',
    'mailchimp_ecommerce_list_id',
    'mailchimp_ecommerce_store_id',
    'mailchimp_ecommerce_integration',
  ];
  foreach ($settings as $variable) {
    if (isset($form[$variable]['#parents'])) {
      $config
        ->set($variable, $form_state
        ->getValue($form[$variable]['#parents']));
    }
  }
  $config
    ->save();
  if (method_exists($this, '_submitForm')) {
    $this
      ->_submitForm($form, $form_state);
  }
  parent::submitForm($form, $form_state);
}