mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
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:
parent
fc9e065e44
commit
f5a91cbbe8
@ -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};
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user