function DbLogController::buildFilterQuery
Same name in other branches
- 8.9.x core/modules/dblog/src/Controller/DbLogController.php \Drupal\dblog\Controller\DbLogController::buildFilterQuery()
- 10 core/modules/dblog/src/Controller/DbLogController.php \Drupal\dblog\Controller\DbLogController::buildFilterQuery()
- 11.x core/modules/dblog/src/Controller/DbLogController.php \Drupal\dblog\Controller\DbLogController::buildFilterQuery()
Builds a query for database log administration filters based on session.
Parameters
\Symfony\Component\HttpFoundation\Request $request: The request.
Return value
array|null An associative array with keys 'where' and 'args' or NULL if there were no filters set.
1 call to DbLogController::buildFilterQuery()
- DbLogController::overview in core/
modules/ dblog/ src/ Controller/ DbLogController.php - Displays a listing of database log messages.
File
-
core/
modules/ dblog/ src/ Controller/ DbLogController.php, line 316
Class
- DbLogController
- Returns responses for dblog routes.
Namespace
Drupal\dblog\ControllerCode
protected function buildFilterQuery(Request $request) {
$session_filters = $request->getSession()
->get('dblog_overview_filter', []);
if (empty($session_filters)) {
return;
}
$this->moduleHandler()
->loadInclude('dblog', 'admin.inc');
$filters = dblog_filters();
// Build query.
$where = $args = [];
foreach ($session_filters 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,
];
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.