You are here

public function MonitoringSettingsForm::buildForm in Monitoring 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/MonitoringSettingsForm.php, line 35
Contains \Drupal\monitoring\Form\MonitoringSettingsForm.

Class

MonitoringSettingsForm
Form for general Monitoring configuration.

Namespace

Drupal\monitoring\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $config = $this
    ->config('monitoring.settings');
  $options = [
    'all' => $this
      ->t('Log all events'),
    'on_request' => $this
      ->t('Log only on request or on status change'),
    'none' => $this
      ->t('No logging'),
  ];
  $form['sensor_call_logging'] = array(
    '#title' => $this
      ->t('Monitoring event logging'),
    '#type' => 'select',
    '#options' => $options,
    '#default_value' => $config
      ->get('sensor_call_logging'),
    '#description' => $this
      ->t('Control local logging of sensor call results.'),
  );
  $form['cron_run_sensors'] = [
    '#title' => $this
      ->t('Run sensors during cron runs'),
    '#type' => 'checkbox',
    '#default_value' => $config
      ->get('cron_run_sensors'),
    '#description' => $this
      ->t('In this mode, monitoring will not be able to detect if cron is running. It is recommended to fetch sensor results with drush or through REST requests for a more reliable setup.'),
  ];
  $form['disable_sensor_autocreate'] = [
    '#title' => $this
      ->t('Disable sensor auto creation'),
    '#type' => 'checkbox',
    '#default_value' => $config
      ->get('disable_sensor_autocreate'),
    '#description' => $this
      ->t('Disable automatic sensor creation. For example: sensors are normally added when node types are added, or new modules are installed.'),
  ];
  return parent::buildForm($form, $form_state);
}