You are here

function LoggerController::buildFilterQuery in MongoDB 8

Build a MongoDB query based on the selected filters.

Return value

array An array to build a MongoDB query.

1 call to LoggerController::buildFilterQuery()
LoggerController::watchdogOverview in src/Logger/LoggerController.php
Display watchdogs entries in mongodb. @TODO Use theme function. Use exposed filter like dblog.

File

src/Logger/LoggerController.php, line 38
Controller service for the MongoDB Watchdog reports.

Class

LoggerController

Namespace

Drupal\mongodb\Logger

Code

function buildFilterQuery() {
  if (empty($_SESSION['mongodb_watchdog_overview_filter'])) {
    return array();
  }

  // Build query.
  $types = $_SESSION['mongodb_watchdog_overview_filter']['type'] ? $_SESSION['mongodb_watchdog_overview_filter']['type'] : NULL;
  $severities = $_SESSION['mongodb_watchdog_overview_filter']['severity'] ? $_SESSION['mongodb_watchdog_overview_filter']['severity'] : NULL;
  $find = array();
  if ($types) {
    $find['type'] = array(
      '$in' => $types,
    );
  }
  if ($severities) {

    // MongoDB is picky about types, ensure the severities are all integers.
    $find['severity'] = array(
      '$in' => array_map('intval', $severities),
    );
  }
  return $find;
}