SystemStatusSettingsForm.php in System Status 8.2
File
src/Form/SystemStatusSettingsForm.php
View source
<?php
namespace Drupal\system_status\Form;
use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;
class SystemStatusSettingsForm extends ConfigFormBase {
public function getFormId() {
return 'system_status_settings';
}
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);
}
protected function getEditableConfigNames() {
return [
'system_status.settings',
];
}
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);
}
}