'pid' =>
['data' =>
t('Person ID'
), 'field' => 'pid'
],
'task' =>
['data' =>
t('Task'
), 'field' => 'task'
],
'priority' =>
['data' =>
t('Priority'
), 'field' => 'priority'
],
];
$query =
$this->connection->
select('test_task', 't'
);
$query ->
fields('t',
['tid', 'pid', 'task', 'priority'
]);
$query =
$query ->
extend(TableSortExtender::
class) ->
orderByHeader($header);
// We need all the results at once to check the sort.
$tasks =
$query->
execute()->
fetchAll();
return new JsonResponse([ 'tasks' =>
$tasks,
]);
} /**
* Runs a tablesort query with a second order_by after and returns the results.
*
* This function does care about the page GET parameter, as set by the
* test HTTP call.
*
* @return \Symfony\Component\HttpFoundation\JsonResponse
*/