You are here

public static function TableSort::getContextFromRequest in Drupal 9

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Utility/TableSort.php \Drupal\Core\Utility\TableSort::getContextFromRequest()

Initializes the table sort context.

Parameters

array $headers: An array of column headers in the format described in '#type' => 'table'.

\Symfony\Component\HttpFoundation\Request $request: A current request.

Return value

array The current table sort context.

3 calls to TableSort::getContextFromRequest()
TableSortExtender::orderByHeader in core/lib/Drupal/Core/Database/Query/TableSortExtender.php
Order the query based on a header array.
TableSortExtenderTest::testTableSortInit in core/tests/Drupal/KernelTests/Core/Render/Element/TableSortExtenderTest.php
Tests \Drupal\Core\Utility\TableSort::getContextFromRequest().
template_preprocess_table in core/includes/theme.inc
Prepares variables for table templates.

File

core/lib/Drupal/Core/Utility/TableSort.php, line 30

Class

TableSort
Provides a class for table sorting processing and rendering.

Namespace

Drupal\Core\Utility

Code

public static function getContextFromRequest(array $headers, Request $request) {
  $context = static::getOrder($headers, $request);
  $context['sort'] = static::getSort($headers, $request);
  $context['query'] = static::getQueryParameters($request);
  return $context;
}