mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
NEW: Make DataList::getIterator a generator
This commit is contained in:
parent
77c7552c3f
commit
1b8f601023
@ -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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user