Permalink
Browse files

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

  • Loading branch information...
1 parent f000a47 commit e9e7655867152d55fc3d83635cc427b25f0d895a @sminnee sminnee committed with stojg Mar 9, 2012
Showing with 32 additions and 3 deletions.
  1. +1 −1 model/ArrayList.php
  2. +1 −1 model/DataList.php
  3. +1 −1 model/ListDecorator.php
  4. +29 −0 model/Sortable.php
View
@@ -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
@@ -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
@@ -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;
View
@@ -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.