You are here

public function MatomoAdminSettingsForm::submitForm in Matomo Analytics 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/MatomoAdminSettingsForm.php, line 654

Class

MatomoAdminSettingsForm
Configure Matomo settings for this site.

Namespace

Drupal\matomo\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $config = $this
    ->config('matomo.settings');
  $config
    ->set('site_id', $form_state
    ->getValue('matomo_site_id'))
    ->set('url_http', $form_state
    ->getValue('matomo_url_http'))
    ->set('url_https', $form_state
    ->getValue('matomo_url_https'))
    ->set('codesnippet.before', $form_state
    ->getValue('matomo_codesnippet_before'))
    ->set('codesnippet.after', $form_state
    ->getValue('matomo_codesnippet_after'))
    ->set('custom.variable', $form_state
    ->getValue('matomo_custom_var'))
    ->set('domain_mode', $form_state
    ->getValue('matomo_domain_mode'))
    ->set('track.files', $form_state
    ->getValue('matomo_trackfiles'))
    ->set('track.files_extensions', $form_state
    ->getValue('matomo_trackfiles_extensions'))
    ->set('track.colorbox', $form_state
    ->getValue('matomo_trackcolorbox'))
    ->set('track.userid', $form_state
    ->getValue('matomo_trackuserid'))
    ->set('track.mailto', $form_state
    ->getValue('matomo_trackmailto'))
    ->set('track.messages', $form_state
    ->getValue('matomo_trackmessages'))
    ->set('track.site_search', $form_state
    ->getValue('matomo_site_search'))
    ->set('page_title_hierarchy', $form_state
    ->getValue('matomo_page_title_hierarchy'))
    ->set('page_title_hierarchy_exclude_home', $form_state
    ->getValue('matomo_page_title_hierarchy_exclude_home'))
    ->set('privacy.donottrack', $form_state
    ->getValue('matomo_privacy_donottrack'))
    ->set('privacy.disablecookies', $form_state
    ->getValue('matomo_privacy_disablecookies'))
    ->set('cache', $form_state
    ->getValue('matomo_cache'))
    ->set('visibility.request_path_mode', $form_state
    ->getValue('matomo_visibility_request_path_mode'))
    ->set('visibility.request_path_pages', $form_state
    ->getValue('matomo_visibility_request_path_pages'))
    ->set('visibility.user_account_mode', $form_state
    ->getValue('matomo_visibility_user_account_mode'))
    ->set('visibility.user_role_mode', $form_state
    ->getValue('matomo_visibility_user_role_mode'))
    ->set('visibility.user_role_roles', $form_state
    ->getValue('matomo_visibility_user_role_roles'))
    ->save();
  if ($form_state
    ->hasValue('matomo_translation_set')) {
    $config
      ->set('translation_set', $form_state
      ->getValue('matomo_translation_set'))
      ->save();
  }
  parent::submitForm($form, $form_state);
}