From 26e5afc0c4781cae34a03c8971a67e7e53adb926 Mon Sep 17 00:00:00 2001 From: Justin Martin Date: Fri, 2 Nov 2012 18:14:04 -0700 Subject: [PATCH] NEW: Add new method "each" to SS_List and core implementors thereof --- model/ArrayList.php | 12 ++++++++++++ model/DataList.php | 14 ++++++++++++++ model/List.php | 8 ++++++++ model/ListDecorator.php | 4 ++++ tests/model/ArrayListTest.php | 15 +++++++++++++++ tests/model/DataListTest.php | 15 +++++++++++++++ 6 files changed, 68 insertions(+) diff --git a/model/ArrayList.php b/model/ArrayList.php index 4335b405c..dc869cd23 100644 --- a/model/ArrayList.php +++ b/model/ArrayList.php @@ -66,6 +66,18 @@ class ArrayList extends ViewableData implements SS_List, SS_Filterable, SS_Sorta public function toArray() { return $this->items; } + + /** + * Walks the list using the specified callback + * + * @param callable $callback + * @return DataList + */ + public function each($callback) { + foreach($this as $item) { + $callback($item); + } + } public function debug() { $val = "

" . $this->class . "