PHP Class Piwik\Metrics\Sorter

Show file Open project: piwik/piwik Class Usage Examples

Public Methods

Method Description
__construct ( Config $config )
getBestSortFlags ( DataTable $table, string | integer $columnToSort ) : integer
getPrimaryColumnToSort ( DataTable $table, string | integer $columnToSort ) : integer Detect the column to be used for sorting
getPrimarySortOrder ( string $order ) : integer
getSecondaryColumnToSort ( Row $row, integer | string $primaryColumnToSort ) : integer Detect the secondary sort column to be used for sorting
getSecondarySortOrder ( string $order, string | integer $secondarySortColumn ) : integer
sort ( DataTable $table ) Sorts the DataTable rows using the supplied callback function.

Private Methods

Method Description
getColumnValue ( Row $row )
getStringSortFlags ( )

Method Details

__construct() public method

public __construct ( Config $config )
$config Piwik\Metrics\Sorter\Config

getBestSortFlags() public method

public getBestSortFlags ( DataTable $table, string | integer $columnToSort ) : integer
$table Piwik\DataTable
$columnToSort string | integer A column name or column id. Make sure that column actually exists in the row. You might want to get a valid column via {@link getPrimaryColumnToSort()} or {@link getSecondaryColumnToSort()}
return integer

getPrimaryColumnToSort() public method

Detect the column to be used for sorting
public getPrimaryColumnToSort ( DataTable $table, string | integer $columnToSort ) : integer
$table Piwik\DataTable
$columnToSort string | integer column name or column id
return integer

getPrimarySortOrder() public method

public getPrimarySortOrder ( string $order ) : integer
$order string 'asc' or 'desc'
return integer

getSecondaryColumnToSort() public method

Detect the secondary sort column to be used for sorting
public getSecondaryColumnToSort ( Row $row, integer | string $primaryColumnToSort ) : integer
$row Piwik\DataTable\Row
$primaryColumnToSort integer | string
return integer

getSecondarySortOrder() public method

public getSecondarySortOrder ( string $order, string | integer $secondarySortColumn ) : integer
$order string 'asc' or 'desc'
$secondarySortColumn string | integer column name or column id
return integer

sort() public method

Sorts the DataTable rows using the supplied callback function.
public sort ( DataTable $table )
$table Piwik\DataTable The table to sort.