You are here

SystemStatusSettingsForm.php in System Status 8

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

Contains \Drupal\pants\Form\PantsSettingsForm.

File

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

/**
 * @file
 * Contains \Drupal\pants\Form\PantsSettingsForm.
 */
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->configFactory
      ->get('system_status.settings');
    $form['system_status_service_allow_drupalstatus'] = array(
      '#type' => 'checkbox',
      '#title' => t('Allow reporting to DrupalStatus.org'),
      '#description' => t('Allow reports to be generated by DrupalStatus. The reports will be stored and send using encryption and are only accessible using your account credentials on DrupalStatus.org'),
      '#default_value' => $config
        ->get('system_status_service_allow_drupalstatus'),
    );
    $form['add_site'] = array(
      '#type' => 'submit',
      '#value' => t('Add this site to your DrupalStatus.org overview'),
      '#submit' => array(
        'system_status_add_site',
      ),
    );
    return parent::buildForm($form, $form_state);
  }

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

  /**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    $config = $this->configFactory
      ->get('system_status.settings');
    $config
      ->set('system_status_service_allow_drupalstatus', $form_state['values']['system_status_service_allow_drupalstatus']);
    $config
      ->save();
    parent::submitForm($form, $form_state);
  }

}

Classes

Namesort descending Description
SystemStatusSettingsForm Configure pants settings for this site.