function TableSort::getContextFromRequest

Same name in other branches
  1. 9 core/lib/Drupal/Core/Utility/TableSort.php \Drupal\Core\Utility\TableSort::getContextFromRequest()
  2. 10 core/lib/Drupal/Core/Utility/TableSort.php \Drupal\Core\Utility\TableSort::getContextFromRequest()
  3. 11.x 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.

4 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().
tablesort_init in core/includes/tablesort.inc
Initializes the table sort context.
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;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.