function TableSortExtender::orderByHeader
Same name in other branches
- 9 core/lib/Drupal/Core/Database/Query/TableSortExtender.php \Drupal\Core\Database\Query\TableSortExtender::orderByHeader()
- 10 core/lib/Drupal/Core/Database/Query/TableSortExtender.php \Drupal\Core\Database\Query\TableSortExtender::orderByHeader()
- 11.x core/lib/Drupal/Core/Database/Query/TableSortExtender.php \Drupal\Core\Database\Query\TableSortExtender::orderByHeader()
Order the query based on a header array.
Parameters
array $header: Table header array.
Return value
\Drupal\Core\Database\Query\SelectInterface The called object.
See also
File
-
core/
lib/ Drupal/ Core/ Database/ Query/ TableSortExtender.php, line 36
Class
- TableSortExtender
- Query extender class for tablesort queries.
Namespace
Drupal\Core\Database\QueryCode
public function orderByHeader(array $header) {
$context = TableSort::getContextFromRequest($header, \Drupal::request());
if (!empty($context['sql'])) {
// Based on code from \Drupal\Core\Database\Connection::escapeTable(),
// but this can also contain a dot.
$field = preg_replace('/[^A-Za-z0-9_.]+/', '', $context['sql']);
// orderBy() will ensure that only ASC/DESC values are accepted, so we
// don't need to sanitize that here.
$this->orderBy($field, $context['sort']);
}
return $this;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.