b6446dfb61bd64174883be01874dfd30a5379ba8
[yaffs-website] / web / core / modules / system / src / Form / LoggingForm.php
1 <?php
2
3 namespace Drupal\system\Form;
4
5 use Drupal\Core\Form\ConfigFormBase;
6 use Drupal\Core\Form\FormStateInterface;
7
8 /**
9  * Configure logging settings for this site.
10  *
11  * @internal
12  */
13 class LoggingForm extends ConfigFormBase {
14
15   /**
16    * {@inheritdoc}
17    */
18   public function getFormId() {
19     return 'system_logging_settings';
20   }
21
22   /**
23    * {@inheritdoc}
24    */
25   protected function getEditableConfigNames() {
26     return ['system.logging'];
27   }
28
29   /**
30    * {@inheritdoc}
31    */
32   public function buildForm(array $form, FormStateInterface $form_state) {
33     $config = $this->config('system.logging');
34     $form['error_level'] = [
35       '#type' => 'radios',
36       '#title' => t('Error messages to display'),
37       '#default_value' => $config->get('error_level'),
38       '#options' => [
39         ERROR_REPORTING_HIDE => t('None'),
40         ERROR_REPORTING_DISPLAY_SOME => t('Errors and warnings'),
41         ERROR_REPORTING_DISPLAY_ALL => t('All messages'),
42         ERROR_REPORTING_DISPLAY_VERBOSE => t('All messages, with backtrace information'),
43       ],
44       '#description' => t('It is recommended that sites running on production environments do not display any errors.'),
45     ];
46
47     return parent::buildForm($form, $form_state);
48   }
49
50   /**
51    * {@inheritdoc}
52    */
53   public function submitForm(array &$form, FormStateInterface $form_state) {
54     $this->config('system.logging')
55       ->set('error_level', $form_state->getValue('error_level'))
56       ->save();
57
58     parent::submitForm($form, $form_state);
59   }
60
61 }