function DbLogFilters::filters

Same name and namespace in other branches
  1. main core/modules/dblog/src/DbLogFilters.php \Drupal\dblog\DbLogFilters::filters()

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.

File

core/modules/dblog/src/DbLogFilters.php, line 42

Class

DbLogFilters
Filter methods for the dblog module.

Namespace

Drupal\dblog

Code

public function filters() : array {
  $filters = [];
  foreach ($this->getMessageTypes() as $type) {
    // phpcs:ignore Drupal.Semantics.FunctionT.NotLiteralString
    $types[$type] = $this->t($type);
  }
  if (!empty($types)) {
    $filters['type'] = [
      'title' => $this->t('Type'),
      'field' => 'w.type',
      'options' => $types,
    ];
  }
  $filters['severity'] = [
    'title' => $this->t('Severity'),
    'field' => 'w.severity',
    'options' => RfcLogLevel::getLevels(),
  ];
  return $filters;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.