API CHANGE: Added SS_Sortable, an extra interface to apply to SS_Lists.

This commit is contained in:
Sam Minnee 2012-03-09 14:28:14 +13:00 committed by Stig Lindqvist
parent f000a47813
commit e9e7655867
4 changed files with 32 additions and 3 deletions

View File

@ -5,7 +5,7 @@
* @package sapphire
* @subpackage model
*/
class ArrayList extends ViewableData implements SS_List, SS_Filterable, SS_Limitable {
class ArrayList extends ViewableData implements SS_List, SS_Filterable, SS_Sortable, SS_Limitable {
/**
* Holds the items in the list

View File

@ -6,7 +6,7 @@
* @package sapphire
* @subpackage model
*/
class DataList extends ViewableData implements SS_List, SS_Filterable, SS_Limitable {
class DataList extends ViewableData implements SS_List, SS_Filterable, SS_Sortable, SS_Limitable {
/**
* The DataObject class name that this data list is querying
*

View File

@ -7,7 +7,7 @@
* @package sapphire
* @subpackage model
*/
abstract class SS_ListDecorator extends ViewableData implements SS_List, SS_Filterable, SS_Limitable {
abstract class SS_ListDecorator extends ViewableData implements SS_List, SS_Sortable, SS_Filterable, SS_Limitable {
protected $list;

29
model/Sortable.php Normal file
View File

@ -0,0 +1,29 @@
<?php
/**
* Additional interface for {@link SS_List} classes that are sortable.
*
* @see SS_List, SS_Filterable, SS_Limitable
*/
interface SS_Sortable {
/**
* Returns TRUE if the list can be sorted by a field.
*
* @param string $by
* @return bool
*/
public function canSortBy($by);
/**
* Sorts this list by one or more fields. You can either pass in a single
* field name and direction, or a map of field names to sort directions.
*
* @example $list->sort('Name'); // default ASC sorting
* @example $list->sort('Name DESC'); // DESC sorting
* @example $list->sort('Name', 'ASC');
* @example $list->sort(array('Name'=>'ASC,'Age'=>'DESC'));
*/
public function sort();
}