Skip to content
This repository
Browse code

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)
  • Loading branch information...
commit f5a91cbbe89f83a0561c1c921fae9cd5db11d3f5 1 parent fc9e065
Sean Harvey authored March 15, 2012

Showing 1 changed file with 6 additions and 2 deletions. Show diff stats Hide diff stats

  1. 8  model/Map.php
8  model/Map.php
@@ -165,7 +165,9 @@ public function rewind() {
165 165
 		if(isset($this->firstItems[$this->firstItemIdx])) {
166 166
 			return $this->firstItems[$this->firstItemIdx][1];
167 167
 		} else {
168  
-			if($rewoundItem) return $rewoundItem->{$this->titleField};
  168
+			if($rewoundItem) return ($rewoundItem->hasMethod($this->titleField))
  169
+				? $rewoundItem->{$this->titleField}()
  170
+				: $rewoundItem->{$this->titleField};
169 171
 		}
170 172
 		
171 173
 	}
@@ -174,7 +176,9 @@ public function current() {
174 176
 		if(isset($this->firstItems[$this->firstItemIdx])) {
175 177
 			return $this->firstItems[$this->firstItemIdx][1];
176 178
 		} else {
177  
-			return $this->items->current()->{$this->titleField};
  179
+			return ($this->items->current()->hasMethod($this->titleField))
  180
+				? $this->items->current()->{$this->titleField}()
  181
+				: $this->items->current()->{$this->titleField};
178 182
 		}
179 183
 	}
180 184
 	

0 notes on commit f5a91cb

Please sign in to comment.
Something went wrong with that request. Please try again.