function QueryBase::tableSort
Same name in other branches
- 8.9.x core/lib/Drupal/Core/Entity/Query/QueryBase.php \Drupal\Core\Entity\Query\QueryBase::tableSort()
- 10 core/lib/Drupal/Core/Entity/Query/QueryBase.php \Drupal\Core\Entity\Query\QueryBase::tableSort()
- 11.x core/lib/Drupal/Core/Entity/Query/QueryBase.php \Drupal\Core\Entity\Query\QueryBase::tableSort()
Overrides QueryInterface::tableSort
File
-
core/
lib/ Drupal/ Core/ Entity/ Query/ QueryBase.php, line 326
Class
- QueryBase
- The base entity query class.
Namespace
Drupal\Core\Entity\QueryCode
public function tableSort(&$headers) {
// If 'field' is not initialized, the header columns aren't clickable.
foreach ($headers as $key => $header) {
if (is_array($header) && isset($header['specifier'])) {
$headers[$key]['field'] = '';
}
}
$order = TableSort::getOrder($headers, \Drupal::request());
$direction = TableSort::getSort($headers, \Drupal::request());
foreach ($headers as $header) {
if (is_array($header) && $header['data'] == $order['name']) {
$this->sort($header['specifier'], $direction, $header['langcode'] ?? NULL);
}
}
return $this;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.