You are here

public function OverviewFilterForm::getFilters in MongoDB 8.2

Creates a list of database log administration filters that can be applied.

Return value

array Associative array of filters. The top-level keys are used as the form element names for the filters, and the values are arrays with the following elements:

  • title: Title of the filter.
  • where: The filter condition.
  • options: Array of options for the select list for the filter.
2 calls to OverviewFilterForm::getFilters()
OverviewFilterForm::buildForm in modules/mongodb_watchdog/src/Form/OverviewFilterForm.php
Form constructor.
OverviewFilterForm::submitForm in modules/mongodb_watchdog/src/Form/OverviewFilterForm.php
Parameter $form is needed by FormInterface, so ignore warning.

File

modules/mongodb_watchdog/src/Form/OverviewFilterForm.php, line 107

Class

OverviewFilterForm
Provides the MongoDB Watchdog overview filter form.

Namespace

Drupal\mongodb_watchdog\Form

Code

public function getFilters() : array {
  $filters = [];
  foreach ($this->watchdog
    ->templateTypes() as $type) {

    // @codingStandardsIgnoreStart
    $types[$type] = $this
      ->t($type);

    // @codingStandardsIgnoreEnd
  }
  if (!empty($types)) {
    $filters['type'] = [
      'title' => $this
        ->t('Type'),
      'where' => "w.type = ?",
      'options' => $types,
    ];
  }
  $filters['severity'] = [
    'title' => $this
      ->t('Severity'),
    'where' => 'w.severity = ?',
    'options' => RfcLogLevel::getLevels(),
  ];
  return $filters;
}