class TableSort (View source)

Provides a class for table sorting processing and rendering.

Constants

ASC

DESC

Methods

static array
getContextFromRequest(array $headers, Request $request)

Initializes the table sort context.

static 
header(string $cell_content, array $cell_attributes, array $header, array $context)

Formats a column header.

static array
getOrder(array $headers, Request $request)

Determines the current sort criterion.

static string
getSort(array $headers, Request $request)

Determines the current sort direction.

static array
getQueryParameters(Request $request)

Composes a URL query parameter array for table sorting links.

Details

static array getContextFromRequest(array $headers, Request $request)

Initializes the table sort context.

Parameters

array $headers

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

Request $request

A current request.

Return Value

array

The current table sort context.

static header(string $cell_content, array $cell_attributes, array $header, array $context)

Formats a column header.

If the cell in question is the column header for the current sort criterion, it gets special formatting. All possible sort criteria become links.

Parameters

string $cell_content

The cell content to format. Passed by reference.

array $cell_attributes

The cell attributes. Passed by reference.

array $header

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

array $context

The current table sort context as returned from TableSort::getContextFromRequest() method.

Exceptions

Exception

See also

getContextFromRequest()

static array getOrder(array $headers, Request $request)

Determines the current sort criterion.

Parameters

array $headers

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

Request $request

A current request.

Return Value

array

An associative array describing the criterion, containing the keys:

  • "name": The localized title of the table column.
  • "sql": The name of the database field to sort on.

static string getSort(array $headers, Request $request)

Determines the current sort direction.

Parameters

array $headers

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

Request $request

A current request.

Return Value

string

The current sort direction ("asc" or "desc").

static array getQueryParameters(Request $request)

internal  
 

Composes a URL query parameter array for table sorting links.

Parameters

Request $request

A current request.

Return Value

array

A URL query parameter array that consists of all components of the current page request except for those pertaining to table sorting.