NEW Add API to create a generator from a DataList (#8931)

This commit is contained in:
Guy Marriott 2019-04-18 15:31:41 +12:00 committed by Aaron Carlino
parent c63eecc3e1
commit 80ad336e97

View File

@ -771,6 +771,20 @@ class DataList extends ViewableData implements SS_List, Filterable, Sortable, Li
return $this;
}
/**
* Returns a generator for this DataList
*
* @return \Generator&DataObject[]
*/
public function getGenerator()
{
$query = $this->dataQuery->query()->execute();
while ($row = $query->record()) {
yield $this->createDataObject($row);
}
}
public function debug()
{
$val = "<h2>" . static::class . "</h2><ul>";