You are here

public function DBLogFilterSettingsForm::buildForm in DBLog Filter 8

Same name and namespace in other branches
  1. 8.2 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 49

Class

DBLogFilterSettingsForm
Settings Form for Dblog Filter.

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 $log_level) {
    $log_level_value = $log_level
      ->getUntranslatedString();
    $severity_levels[strtolower($log_level_value)] = $log_level_value;
  }
  $form['severity_levels'] = array(
    '#type' => 'checkboxes',
    '#title' => $this
      ->t('Select Severity Levels'),
    '#description' => $this
      ->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>' . $this
    ->t('Enter one value per line, in the format
      log_type|level1,level2,level3.. to restrict the log messages stored');
  $description .= '<br/><b>' . $this
    ->t('Example: php|error,notice,warning');
  $description .= '<br/>' . $this
    ->t('mymodule|error,notice') . '</b>';
  $description .= '</p>';
  $form['description'] = array(
    '#markup' => $description,
  );
  return parent::buildForm($form, $form_state);
}