NEW: Make DataList::getIterator a generator

This commit is contained in:
Loz Calver 2017-01-12 14:56:11 +00:00 committed by Guy Sartorelli
parent 77c7552c3f
commit 1b8f601023
No known key found for this signature in database
GPG Key ID: F313E3B9504D496A

View File

@ -864,12 +864,14 @@ class DataList extends ViewableData implements SS_List, Filterable, Sortable, Li
* Returns an Iterator for this DataList. * Returns an Iterator for this DataList.
* This function allows you to use DataLists in foreach loops * This function allows you to use DataLists in foreach loops
* *
* @return ArrayIterator * @return Generator
*/ */
#[\ReturnTypeWillChange] #[\ReturnTypeWillChange]
public function getIterator() public function getIterator()
{ {
return new ArrayIterator($this->toArray()); foreach ($this->dataQuery->query()->execute() as $row) {
yield $this->createDataObject($row);
}
} }
/** /**