Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

API CHANGE: Added SS_Filterable, an extra interface to apply to lists.

  • Loading branch information...
commit f000a47813ca94766aab727893bf7a2985a22058 1 parent a55e06f
@sminnee sminnee authored stojg committed
View
2  model/ArrayList.php
@@ -5,7 +5,7 @@
* @package sapphire
* @subpackage model
*/
-class ArrayList extends ViewableData implements SS_List, SS_Limitable {
+class ArrayList extends ViewableData implements SS_List, SS_Filterable, SS_Limitable {
/**
* Holds the items in the list
View
2  model/DataList.php
@@ -6,7 +6,7 @@
* @package sapphire
* @subpackage model
*/
-class DataList extends ViewableData implements SS_List, SS_Limitable {
+class DataList extends ViewableData implements SS_List, SS_Filterable, SS_Limitable {
/**
* The DataObject class name that this data list is querying
*
View
40 model/Filterable.php
@@ -0,0 +1,40 @@
+<?php
+
+/**
+ * Additional interface for {@link SS_List} classes that are filterable.
+ *
+ * @see SS_List, SS_Sortable, SS_Limitable
+ */
+interface SS_Filterable {
+
+ /**
+ * Returns TRUE if the list can be filtered by a given field expression.
+ *
+ * @param string $by
+ * @return bool
+ */
+ public function canFilterBy($by);
+
+ /**
+ * Filter the list to include items with these charactaristics
+ *
+ * @example $list->filter('Name', 'bob'); // only bob in the list
+ * @example $list->filter('Name', array('aziz', 'bob'); // aziz and bob in list
+ * @example $list->filter(array('Name'=>'bob, 'Age'=>21)); // bob with the age 21
+ * @example $list->filter(array('Name'=>'bob, 'Age'=>array(21, 43))); // bob with the Age 21 or 43
+ * @example $list->filter(array('Name'=>array('aziz','bob'), 'Age'=>array(21, 43))); // aziz with the age 21 or 43 and bob with the Age 21 or 43
+ */
+ public function filter();
+
+ /**
+ * Exclude the list to not contain items with these charactaristics
+ *
+ * @example $list->exclude('Name', 'bob'); // exclude bob from list
+ * @example $list->exclude('Name', array('aziz', 'bob'); // exclude aziz and bob from list
+ * @example $list->exclude(array('Name'=>'bob, 'Age'=>21)); // exclude bob that has Age 21
+ * @example $list->exclude(array('Name'=>'bob, 'Age'=>array(21, 43))); // exclude bob with Age 21 or 43
+ * @example $list->exclude(array('Name'=>array('bob','phil'), 'Age'=>array(21, 43))); // bob age 21 or 43, phil age 21 or 43 would be excluded
+ */
+ public function exclude();
+
+}
View
41 model/List.php
@@ -78,45 +78,4 @@ public function find($key, $value);
*/
public function column($colName = "ID");
- /**
- * 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();
-
- /**
- * Filter the list to include items with these charactaristics
- *
- * @example $list->filter('Name', 'bob'); // only bob in the list
- * @example $list->filter('Name', array('aziz', 'bob'); // aziz and bob in list
- * @example $list->filter(array('Name'=>'bob, 'Age'=>21)); // bob with the age 21
- * @example $list->filter(array('Name'=>'bob, 'Age'=>array(21, 43))); // bob with the Age 21 or 43
- * @example $list->filter(array('Name'=>array('aziz','bob'), 'Age'=>array(21, 43))); // aziz with the age 21 or 43 and bob with the Age 21 or 43
- */
- public function filter();
-
- /**
- * Exclude the list to not contain items with these charactaristics
- *
- * @example $list->exclude('Name', 'bob'); // exclude bob from list
- * @example $list->exclude('Name', array('aziz', 'bob'); // exclude aziz and bob from list
- * @example $list->exclude(array('Name'=>'bob, 'Age'=>21)); // exclude bob that has Age 21
- * @example $list->exclude(array('Name'=>'bob, 'Age'=>array(21, 43))); // exclude bob with Age 21 or 43
- * @example $list->exclude(array('Name'=>array('bob','phil'), 'Age'=>array(21, 43))); // bob age 21 or 43, phil age 21 or 43 would be excluded
- */
- public function exclude();
-
}
View
6 model/ListDecorator.php
@@ -7,7 +7,7 @@
* @package sapphire
* @subpackage model
*/
-abstract class SS_ListDecorator extends ViewableData implements SS_List, S_Limitable {
+abstract class SS_ListDecorator extends ViewableData implements SS_List, SS_Filterable, SS_Limitable {
protected $list;
@@ -119,6 +119,10 @@ public function sort() {
return call_user_func_array(array($this->list, 'sort'), $args);
}
+ public function canFilterBy($by) {
+ return $this->list->canFilterBy($by);
+ }
+
/**
* Filter the list to include items with these charactaristics
*
Please sign in to comment.
Something went wrong with that request. Please try again.