LoggingForm.php 1.5 KB

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