You are here

public function SimpleFacebookPixelSettingsForm::submitForm in Simple Facebook Pixel 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/SimpleFacebookPixelSettingsForm.php, line 311

Class

SimpleFacebookPixelSettingsForm
Class SimpleFacebookPixelSettingsForm.

Namespace

Drupal\simple_facebook_pixel\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $values = $form_state
    ->getValues();
  $config = $this
    ->config('simple_facebook_pixel.settings')
    ->set('pixel_enabled', $values['pixel_enabled'])
    ->set('pixel_id', $values['pixel_id'])
    ->set('exclude_admin_pages', $values['exclude_admin_pages'])
    ->set('excluded_roles', $values['excluded_roles'])
    ->set('view_content_entities', $values['view_content_entities'])
    ->set('complete_registration_enabled', $values['complete_registration_enabled']);
  if ($this->moduleHandler
    ->moduleExists('commerce_checkout')) {
    $config
      ->set('initiate_checkout_enabled', $values['initiate_checkout_enabled'])
      ->set('purchase_enabled', $values['purchase_enabled'])
      ->set('add_to_cart_enabled', $values['add_to_cart_enabled']);
  }
  if ($this->moduleHandler
    ->moduleExists('commerce_wishlist')) {
    $config
      ->set('add_to_wishlist_enabled', $values['add_to_wishlist_enabled']);
  }
  if ($this->moduleHandler
    ->moduleExists('flag')) {
    $config
      ->set('add_to_wishlist_flag_enabled', $values['add_to_wishlist_flag_enabled'])
      ->set('add_to_wishlist_flag_list', $values['add_to_wishlist_flag_list']);
  }
  $config
    ->save();
  parent::submitForm($form, $form_state);
}