Skip to content

Commit

Permalink
API CHANGE: Added SS_Sortable, an extra interface to apply to SS_Lists.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam Minnee authored and Stig Lindqvist committed Mar 9, 2012
1 parent f000a47 commit e9e7655
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 3 deletions.
2 changes: 1 addition & 1 deletion model/ArrayList.php
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion model/DataList.php
Expand Up @@ -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
*
Expand Down
2 changes: 1 addition & 1 deletion model/ListDecorator.php
Expand Up @@ -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;

Expand Down
29 changes: 29 additions & 0 deletions model/Sortable.php
@@ -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();

}

0 comments on commit e9e7655

Please sign in to comment.