You are here

public function AnalyticsSettingsForm::buildForm in Analytics 8

Form constructor.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

array The form structure.

Overrides ConfigFormBase::buildForm

File

src/Form/AnalyticsSettingsForm.php, line 30

Class

AnalyticsSettingsForm
Settings form for the Analytics module.

Namespace

Drupal\analytics\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $config = $this
    ->config('analytics.settings');
  $form['privacy'] = [
    '#type' => 'fieldset',
    '#title' => $this
      ->t('Privacy'),
    '#tree' => TRUE,
  ];
  $form['privacy']['dnt'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Respect Do Not Track (DNT) cookies.'),
    '#default_value' => $config
      ->get('privacy.dnt'),
  ];
  $form['privacy']['disable_floc'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Opt out of <a href=":link">Federated Learning of Cohorts (FLoC) browser-based targeted advertising tracking</a>.', [
      ':link' => 'https://www.eff.org/deeplinks/2021/03/googles-floc-terrible-idea',
    ]),
    '#default_value' => $config
      ->get('privacy.disable_floc'),
  ];
  $form['advanced'] = [
    '#type' => 'details',
    '#title' => $this
      ->t('Advanced'),
    '#open' => FALSE,
  ];
  $form['advanced']['cache_urls'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Cache files locally where possible.'),
    '#default_value' => $config
      ->get('cache_urls'),
  ];
  $form['advanced']['disable_page_build'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Disable default analytics service rendering in hook_page_bottom().'),
    '#default_value' => $config
      ->get('disable_page_build'),
  ];
  return parent::buildForm($form, $form_state);
}