Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
15 / 15
100.00% covered (success)
100.00%
4 / 4
CRAP
100.00% covered (success)
100.00%
1 / 1
AuthorizationSettingsForm
100.00% covered (success)
100.00%
15 / 15
100.00% covered (success)
100.00%
4 / 4
4
100.00% covered (success)
100.00%
1 / 1
 getFormId
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getEditableConfigNames
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
1
 buildForm
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
1 / 1
1
 submitForm
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5namespace Drupal\authorization\Form;
6
7use Drupal\Core\Form\ConfigFormBase;
8use Drupal\Core\Form\FormStateInterface;
9
10/**
11 * Configure authorization settings for this site.
12 */
13class AuthorizationSettingsForm extends ConfigFormBase {
14
15  /**
16   * {@inheritdoc}
17   */
18  public function getFormId(): string {
19    return 'authorization_settings';
20  }
21
22  /**
23   * {@inheritdoc}
24   */
25  protected function getEditableConfigNames(): array {
26    return [
27      'authorization.settings',
28    ];
29  }
30
31  /**
32   * {@inheritdoc}
33   */
34  public function buildForm(array $form, FormStateInterface $form_state): array {
35    $config = $this->config('authorization.settings');
36
37    $form['authorization_message'] = [
38      '#type' => 'checkbox',
39      '#title' => $this->t('If enabled, all authorization and notification messages will be shown to the user.'),
40      '#default_value' => $config->get('authorization_message'),
41    ];
42
43    return parent::buildForm($form, $form_state);
44  }
45
46  /**
47   * {@inheritdoc}
48   */
49  public function submitForm(array &$form, FormStateInterface $form_state): void {
50    $this->config('authorization.settings')
51      ->set('authorization_message', $form_state->getValue('authorization_message'))
52      ->save();
53
54    parent::submitForm($form, $form_state);
55  }
56
57}