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)
This commit is contained in:
Sean Harvey 2012-03-15 17:28:00 +13:00
parent fc9e065e44
commit f5a91cbbe8

View File

@ -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};
}
}