You are here

protected function ContentLogController::buildFilterQuery in Content Synchronization 8.2

Same name and namespace in other branches
  1. 8 src/Controller/ContentLogController.php \Drupal\content_sync\Controller\ContentLogController::buildFilterQuery()
  2. 3.0.x src/Controller/ContentLogController.php \Drupal\content_sync\Controller\ContentLogController::buildFilterQuery()

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

Return value

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

1 call to ContentLogController::buildFilterQuery()
ContentLogController::overview in src/Controller/ContentLogController.php
Displays a listing of database log messages.

File

src/Controller/ContentLogController.php, line 307

Class

ContentLogController
Returns responses for content_sync routes.

Namespace

Drupal\content_sync\Controller

Code

protected function buildFilterQuery() {
  if (empty($_SESSION['cslog_overview_filter'])) {
    return;
  }
  $this->moduleHandler
    ->loadInclude('content_sync', 'admin.inc');
  $filters = cs_log_filters();

  // Build query.
  $where = $args = [];
  foreach ($_SESSION['cslog_overview_filter'] as $key => $filter) {
    $filter_where = [];
    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 [
    'where' => $where,
    'args' => $args,
  ];
}