You are here

public function SettingsForm::buildForm in Drupalmonitor 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/SettingsForm.php, line 64

Class

SettingsForm
Class SettingsForm.

Namespace

Drupal\drupalmonitor\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $form['drupalmonitor_hash'] = [
    '#type' => 'textfield',
    '#title' => t('Security Hash'),
    '#default_value' => $this->drupalMonitorSettings
      ->getHash(),
    '#required' => TRUE,
    '#description' => $this
      ->t('Security hash which will be used to protect the access @link.', [
      '@link' => Url::fromRoute('drupalmonitor.drupalmonitor', [], [
        'absolute' => TRUE,
      ])
        ->toString(),
    ]),
  ];
  $form['metrics'] = [
    '#type' => 'fieldset',
    '#title' => $this
      ->t('Metrics'),
    '#description' => $this
      ->t('Enable all the metric Drupalmonitor should list.'),
  ];
  $form['metrics'][Settings::CONFIG_KEY_SERVER_MONITORING] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Server'),
    '#default_value' => $this->drupalMonitorSettings
      ->isServerMonitoringEnabled(),
  ];
  $form['metrics'][Settings::CONFIG_KEY_USER_MONITORING] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('User'),
    '#default_value' => $this->drupalMonitorSettings
      ->isUserMonitoringEnabled(),
  ];
  $form['metrics'][Settings::CONFIG_KEY_FILES_MONITORING] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Files'),
    '#default_value' => $this->drupalMonitorSettings
      ->isFilesMonitoringEnabled(),
  ];
  $form['metrics'][Settings::CONFIG_KEY_NODE_MONITORING] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Nodes'),
    '#default_value' => $this->drupalMonitorSettings
      ->isNodeMonitoringEnabled(),
  ];
  $form['metrics'][Settings::CONFIG_KEY_MODULES_MONITORING] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Modules'),
    '#default_value' => $this->drupalMonitorSettings
      ->isModulesMonitoringEnabled(),
  ];
  $form['metrics'][Settings::CONFIG_KEY_VARIABLES_MONITORING] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Variables / Configurations'),
    '#default_value' => $this->drupalMonitorSettings
      ->isVariablesMonitoringEnabled(),
  ];
  $form['submit'] = [
    '#type' => 'submit',
    '#value' => $this
      ->t('Submit'),
  ];
  return $form;
}