You are here

public function WSDataAdminForm::buildForm in Web Service Data 8

Same name and namespace in other branches
  1. 2.0.x src/Form/WSDataAdminForm.php \Drupal\wsdata\Form\WSDataAdminForm::buildForm()

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/WSDataAdminForm.php, line 60

Class

WSDataAdminForm
Admin form for the WSData module.

Namespace

Drupal\wsdata\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $disable = TRUE;

  // Only allow this if the devel module is enabled.
  if ($this->module_handler
    ->moduleExists('kint')) {
    $disable = FALSE;
  }
  else {
    $this->state
      ->set('wsdata_debug_mode', 0);
  }
  $form['debug_mode'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Debug Mode'),
    '#description' => $this
      ->t('Devel and Kink modules must be installed and enabled for this functionality to work.'),
    '#disabled' => $disable,
    '#default_value' => $this->state
      ->get('wsdata_debug_mode'),
  ];
  $form['performance_log'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Performance log'),
    '#description' => $this
      ->t('Log WSData performace to watchdog'),
    '#default_value' => $this->state
      ->get('wsdata_performance_log', 0),
  ];
  return parent::buildForm($form, $form_state);
}