DbLogController::buildFilterQuery

protected DbLogController::buildFilterQuery()

Builds a query for database log administration filters based on session.

Return value

array An associative array with keys 'where' and 'args'.

File

core/modules/dblog/src/Controller/DbLogController.php, line 304

Class

DbLogController
Returns responses for dblog routes.

Namespace

Drupal\dblog\Controller

Code

protected function buildFilterQuery() {
  if (empty($_SESSION['dblog_overview_filter'])) {
    return;
  }

  $this->moduleHandler->loadInclude('dblog', 'admin.inc');

  $filters = dblog_filters();

  // Build query.
  $where = $args = array();
  foreach ($_SESSION['dblog_overview_filter'] as $key => $filter) {
    $filter_where = array();
    foreach ($filter as $value) {
      $filter_where[] = $filters[$key]['where'];
      $args[] = $value;
    }
    if (!empty($filter_where)) {
      $where[] = '(' . implode(' OR ', $filter_where) . ')';
    }
  }
  $where = !empty($where) ? implode(' AND ', $where) : '';

  return array(
    'where' => $where,
    'args' => $args,
  );
}
doc_Drupal
2016-10-29 09:01:15
Comments
Leave a Comment

Please login to continue.