You are here

public function PiwikAdminSettingsForm::submitForm in Piwik Web 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/PiwikAdminSettingsForm.php, line 568

Class

PiwikAdminSettingsForm
Configure Piwik settings for this site.

Namespace

Drupal\piwik\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $config = $this
    ->config('piwik.settings');
  $config
    ->set('site_id', $form_state
    ->getValue('piwik_site_id'))
    ->set('url_http', $form_state
    ->getValue('piwik_url_http'))
    ->set('url_https', $form_state
    ->getValue('piwik_url_https'))
    ->set('codesnippet.before', $form_state
    ->getValue('piwik_codesnippet_before'))
    ->set('codesnippet.after', $form_state
    ->getValue('piwik_codesnippet_after'))
    ->set('custom.variable', $form_state
    ->getValue('piwik_custom_var'))
    ->set('domain_mode', $form_state
    ->getValue('piwik_domain_mode'))
    ->set('track.files', $form_state
    ->getValue('piwik_trackfiles'))
    ->set('track.files_extensions', $form_state
    ->getValue('piwik_trackfiles_extensions'))
    ->set('track.colorbox', $form_state
    ->getValue('piwik_trackcolorbox'))
    ->set('track.userid', $form_state
    ->getValue('piwik_trackuserid'))
    ->set('track.mailto', $form_state
    ->getValue('piwik_trackmailto'))
    ->set('track.messages', $form_state
    ->getValue('piwik_trackmessages'))
    ->set('track.site_search', $form_state
    ->getValue('piwik_site_search'))
    ->set('privacy.donottrack', $form_state
    ->getValue('piwik_privacy_donottrack'))
    ->set('cache', $form_state
    ->getValue('piwik_cache'))
    ->set('visibility.request_path_mode', $form_state
    ->getValue('piwik_visibility_request_path_mode'))
    ->set('visibility.request_path_pages', $form_state
    ->getValue('piwik_visibility_request_path_pages'))
    ->set('visibility.user_account_mode', $form_state
    ->getValue('piwik_visibility_user_account_mode'))
    ->set('visibility.user_role_mode', $form_state
    ->getValue('piwik_visibility_user_role_mode'))
    ->set('visibility.user_role_roles', $form_state
    ->getValue('piwik_visibility_user_role_roles'))
    ->save();
  if ($form_state
    ->hasValue('piwik_translation_set')) {
    $config
      ->set('translation_set', $form_state
      ->getValue('piwik_translation_set'))
      ->save();
  }
  parent::submitForm($form, $form_state);
}