From f5a91cbbe89f83a0561c1c921fae9cd5db11d3f5 Mon Sep 17 00:00:00 2001 From: Sean Harvey Date: Thu, 15 Mar 2012 17:28:00 +1300 Subject: [PATCH] ENHANCEMENT SS_Map_Iterator::rewind() SS_Map_Iterator::current() will return the titleField if there's a method of the same name (same behaviour as DataObjectSet::map() from SS 2.4) --- model/Map.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/model/Map.php b/model/Map.php index 086e82baa..02a0b3dc0 100644 --- a/model/Map.php +++ b/model/Map.php @@ -165,7 +165,9 @@ class SS_Map_Iterator implements Iterator { if(isset($this->firstItems[$this->firstItemIdx])) { return $this->firstItems[$this->firstItemIdx][1]; } else { - if($rewoundItem) return $rewoundItem->{$this->titleField}; + if($rewoundItem) return ($rewoundItem->hasMethod($this->titleField)) + ? $rewoundItem->{$this->titleField}() + : $rewoundItem->{$this->titleField}; } } @@ -174,7 +176,9 @@ class SS_Map_Iterator implements Iterator { if(isset($this->firstItems[$this->firstItemIdx])) { return $this->firstItems[$this->firstItemIdx][1]; } else { - return $this->items->current()->{$this->titleField}; + return ($this->items->current()->hasMethod($this->titleField)) + ? $this->items->current()->{$this->titleField}() + : $this->items->current()->{$this->titleField}; } }