mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-09-30 05:09:06 +02:00
NEW Add API to create a generator from a DataList (#8931)
This commit is contained in:
parent
c63eecc3e1
commit
80ad336e97
@ -771,6 +771,20 @@ class DataList extends ViewableData implements SS_List, Filterable, Sortable, Li
|
|||||||
return $this;
|
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()
|
public function debug()
|
||||||
{
|
{
|
||||||
$val = "<h2>" . static::class . "</h2><ul>";
|
$val = "<h2>" . static::class . "</h2><ul>";
|
||||||
|
Loading…
Reference in New Issue
Block a user