BlueSpice MediaWiki master
 All Classes Namespaces Files Functions Variables Groups Pages
BlueSpice\Data\Sorter Class Reference

Public Member Functions

 __construct ($sorts)
 
 sort ($dataSets, $unsortableProps=[])
 

Protected Member Functions

 getSortFlags ($property)
 
 getSortValue ($dataSet, $property)
 
 getSortValueFromList ($values, $dataSet, $property)
 
 canBeCastedToString ($value)
 
 getSortDirection ($sort)
 

Protected Attributes

 $sorts = null
 

Constructor & Destructor Documentation

BlueSpice\Data\Sorter::__construct (   $sorts)
Parameters
Sort[]$sorts

Member Function Documentation

BlueSpice\Data\Sorter::canBeCastedToString (   $value)
protected

Checks if a array or object ist castable to string.

Parameters
mixed$value
Returns
bool
BlueSpice\Data\Sorter::getSortDirection (   $sort)
protected
Parameters
Sort$sort
Returns
int Constant value of SORT_ASC or SORT_DESC
BlueSpice\Data\Sorter::getSortFlags (   $property)
protected

Returns the flags for PHP 'array_multisort' function May be overridden by subclasses to provide different sort flags depending on the property

Parameters
string$property
Returns
int see http://php.net/manual/en/array.constants.php for details
BlueSpice\Data\Sorter::getSortValue (   $dataSet,
  $property 
)
protected

Returns the value a for a field a dataset is being sorted by. May be overridden by subclass to allow custom sorting

Parameters
\BlueSpice\Data\Record$dataSet
string$property
Returns
string
BlueSpice\Data\Sorter::getSortValueFromList (   $values,
  $dataSet,
  $property 
)
protected

Normalizes an array to a string value that can be used in sort logic. May be overridden by subclass to customize sorting. Assumes that array entries can be casted to string.

Parameters
array$values
\BlueSpice\Data\Record$dataSet
string$property
Returns
string
BlueSpice\Data\Sorter::sort (   $dataSets,
  $unsortableProps = [] 
)
Parameters
\BlueSpice\Data\Record[]$dataSets
array$unsortableProps
Returns
[]

The documentation for this class was generated from the following file: