You are here

public function DBLogFilterSettingsForm::buildForm in DBLog Filter 8.2

Same name and namespace in other branches
  1. 8 src/Form/DBLogFilterSettingsForm.php \Drupal\dblog_filter\Form\DBLogFilterSettingsForm::buildForm()

Form constructor.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

array The form structure.

Overrides ConfigFormBase::buildForm

File

src/Form/DBLogFilterSettingsForm.php, line 46

Class

DBLogFilterSettingsForm

Namespace

Drupal\dblog_filter\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $config = $this
    ->config('dblog_filter.settings');
  $log_levels = RfcLogLevel::getLevels();
  foreach ($log_levels as $key => $log_level) {
    $log_level_value = $log_level
      ->getUntranslatedString();
    $severity_levels[strtolower($log_level_value)] = $log_level_value;
  }
  $form['severity_levels'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Select Severity Levels'),
    '#description' => t('Only the selected severity logs will be recorded'),
    '#options' => $severity_levels,
    '#default_value' => $config
      ->get('severity_levels'),
  );
  $form['log_values'] = array(
    '#type' => 'textarea',
    '#title' => $this
      ->t('Enter DB Log type and Severity Levels.'),
    '#default_value' => $config
      ->get('log_values'),
  );
  $levels = '<i>Severity Levels: emergency, alert, critical, error, ' . 'warning, notice, info, debug</i>';
  $log_types = '<i>Log Types: php, cron, mail, mymodule, etc.</i>';
  $description = $levels;
  $description .= '<br/>' . $log_types;
  $description .= '<p>' . t('Enter one value per line, ' . 'in the format log_type|level1,level2,level3.. to restrict the
            log messages stored');
  $description .= '<br/>' . t('<b>Example: php|error,notice,warning ' . '<br> mymodule|error,notice</b>');
  $description .= '</p>';
  $form['description'] = array(
    '#markup' => $description,
  );
  return parent::buildForm($form, $form_state);
}