Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
namespace Drupal\automatic_updates\Form;
use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;
/**
* Administration form for automatic updates.
*/
class AdminForm extends ConfigFormBase {
/**
* {@inheritdoc}
*/
protected function getEditableConfigNames() {
return [
'automatic_updates.settings',
];
}
/**
* {@inheritdoc}
*/
public function getFormId() {
return 'automatic_updates_admin_form';
}
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this->config('automatic_updates.settings');
$form['enable_psa'] = [
'#type' => 'checkbox',
'#title' => $this->t('Enable messaging of public service alerts (PSAs)'),
'#default_value' => $config->get('enable_psa'),
];
return parent::buildForm($form, $form_state);
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
parent::submitForm($form, $form_state);
$form_state->cleanValues();
$config = $this->config('automatic_updates.settings');
foreach ($form_state->getValues() as $key => $value) {
$config->set($key, $value);
}
$config->save();
}
}