You are here

public function GoogleAnalyticsAdminSettingsForm::submitForm in Google Analytics 8.3

Same name and namespace in other branches
  1. 8.2 src/Form/GoogleAnalyticsAdminSettingsForm.php \Drupal\google_analytics\Form\GoogleAnalyticsAdminSettingsForm::submitForm()
  2. 4.x src/Form/GoogleAnalyticsAdminSettingsForm.php \Drupal\google_analytics\Form\GoogleAnalyticsAdminSettingsForm::submitForm()

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/GoogleAnalyticsAdminSettingsForm.php, line 683

Class

GoogleAnalyticsAdminSettingsForm
Configure Google_Analytics settings for this site.

Namespace

Drupal\google_analytics\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $config = $this
    ->config('google_analytics.settings');
  $config
    ->set('account', $form_state
    ->getValue('google_analytics_account'))
    ->set('premium', $form_state
    ->getValue('google_analytics_premium'))
    ->set('cross_domains', $form_state
    ->getValue('google_analytics_cross_domains'))
    ->set('codesnippet.create', $form_state
    ->getValue('google_analytics_codesnippet_create'))
    ->set('codesnippet.before', $form_state
    ->getValue('google_analytics_codesnippet_before'))
    ->set('codesnippet.after', $form_state
    ->getValue('google_analytics_codesnippet_after'))
    ->set('custom.dimension', $form_state
    ->getValue('google_analytics_custom_dimension'))
    ->set('custom.metric', $form_state
    ->getValue('google_analytics_custom_metric'))
    ->set('domain_mode', $form_state
    ->getValue('google_analytics_domain_mode'))
    ->set('track.files', $form_state
    ->getValue('google_analytics_trackfiles'))
    ->set('track.files_extensions', $form_state
    ->getValue('google_analytics_trackfiles_extensions'))
    ->set('track.colorbox', $form_state
    ->getValue('google_analytics_trackcolorbox'))
    ->set('track.linkid', $form_state
    ->getValue('google_analytics_tracklinkid'))
    ->set('track.urlfragments', $form_state
    ->getValue('google_analytics_trackurlfragments'))
    ->set('track.userid', $form_state
    ->getValue('google_analytics_trackuserid'))
    ->set('track.mailto', $form_state
    ->getValue('google_analytics_trackmailto'))
    ->set('track.messages', $form_state
    ->getValue('google_analytics_trackmessages'))
    ->set('track.outbound', $form_state
    ->getValue('google_analytics_trackoutbound'))
    ->set('track.site_search', $form_state
    ->getValue('google_analytics_site_search'))
    ->set('track.adsense', $form_state
    ->getValue('google_analytics_trackadsense'))
    ->set('track.displayfeatures', $form_state
    ->getValue('google_analytics_trackdisplayfeatures'))
    ->set('privacy.anonymizeip', $form_state
    ->getValue('google_analytics_tracker_anonymizeip'))
    ->set('cache', $form_state
    ->getValue('google_analytics_cache'))
    ->set('debug', $form_state
    ->getValue('google_analytics_debug'))
    ->set('visibility.request_path_mode', $form_state
    ->getValue('google_analytics_visibility_request_path_mode'))
    ->set('visibility.request_path_pages', $form_state
    ->getValue('google_analytics_visibility_request_path_pages'))
    ->set('visibility.user_role_mode', $form_state
    ->getValue('google_analytics_visibility_user_role_mode'))
    ->set('visibility.user_role_roles', $form_state
    ->getValue('google_analytics_visibility_user_role_roles'))
    ->set('visibility.user_account_mode', $form_state
    ->getValue('google_analytics_visibility_user_account_mode'))
    ->save();
  if ($form_state
    ->hasValue('google_analytics_translation_set')) {
    $config
      ->set('translation_set', $form_state
      ->getValue('google_analytics_translation_set'))
      ->save();
  }
  parent::submitForm($form, $form_state);
}