Same filename and directory in other branches
- 8.9.x core/lib/Drupal/Core/Database/Query/TableSortExtender.php
- 9 core/lib/Drupal/Core/Database/Query/TableSortExtender.php
Namespace
Drupal\Core\Database\Query
File
core/lib/Drupal/Core/Database/Query/TableSortExtender.php
View source
<?php
namespace Drupal\Core\Database\Query;
use Drupal\Core\Database\Connection;
use Drupal\Core\Utility\TableSort;
class TableSortExtender extends SelectExtender {
public function __construct(SelectInterface $query, Connection $connection) {
parent::__construct($query, $connection);
$this
->addTag('tablesort');
}
public function orderByHeader(array $header) {
$context = TableSort::getContextFromRequest($header, \Drupal::request());
if (!empty($context['sql'])) {
$field = preg_replace('/[^A-Za-z0-9_.]+/', '', $context['sql']);
$this
->orderBy($field, $context['sort']);
}
return $this;
}
}
Classes