You are here

SystemStatusSettingsForm.php in System Status 8.2

Same filename and directory in other branches
  1. 8 src/Form/SystemStatusSettingsForm.php

File

src/Form/SystemStatusSettingsForm.php
View source
<?php

namespace Drupal\system_status\Form;

use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;

/**
 * Configure pants settings for this site.
 */
class SystemStatusSettingsForm extends ConfigFormBase {

  /**
   * {@inheritdoc}
   */
  public function getFormId() {
    return 'system_status_settings';
  }

  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state) {
    $config = $this
      ->config('system_status.settings');
    $form['system_status_service'] = [
      '#type' => 'textfield',
      '#title' => $this
        ->t('Your siteUUID'),
      '#description' => $config
        ->get('system_status_token') . "-" . $config
        ->get('system_status_encrypt_token'),
      '#default_value' => $config
        ->get('system_status_token') . "-" . $config
        ->get('system_status_encrypt_token'),
      '#attributes' => [
        'style' => [
          'display:none;',
        ],
      ],
      '#size' => 60,
      '#maxlength' => 60,
      '#disabled' => TRUE,
    ];
    $form['system_status_service_allow_external'] = [
      '#type' => 'checkbox',
      '#title' => $this
        ->t('Allow external services to fetch this site'),
      '#description' => $this
        ->t('Allow reports to be generated by external services. <br>All information will be sent using encryption and is only accessible using your siteUUID.'),
      '#default_value' => TRUE,
      '#disabled' => TRUE,
      '#default_value' => $config
        ->get('system_status_service_allow_external'),
    ];
    return parent::buildForm($form, $form_state);
  }

  /**
   * {@inheritdoc}
   */
  protected function getEditableConfigNames() {
    return [
      'system_status.settings',
    ];
  }

  /**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    $this
      ->config('system_status.settings')
      ->set('system_status_service_allow_external', $form_state
      ->getValue('system_status_service_allow_external'))
      ->save();
    parent::submitForm($form, $form_state);
  }

}

Classes

Namesort descending Description
SystemStatusSettingsForm Configure pants settings for this site.