API Remove unnecessary getGenerator() method.

`getIterator()` now returns a generator by default.
This commit is contained in:
Guy Sartorelli 2022-08-11 15:04:52 +12:00
parent bf331072df
commit a76fa32a39
No known key found for this signature in database
GPG Key ID: F313E3B9504D496A
2 changed files with 1 additions and 19 deletions

View File

@ -223,10 +223,6 @@ class GridFieldExportButton extends AbstractGridFieldComponent implements GridFi
// Remove limit as the list may be paginated, we want the full list for the export
$items = $items->limit(null);
// Use Generator in applicable cases to reduce memory consumption
$items = $items instanceof DataList
? $items->getGenerator()
: $items;
/** @var DataObject $item */
foreach ($items as $item) {

View File

@ -790,20 +790,6 @@ 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>";
@ -1214,7 +1200,7 @@ class DataList extends ViewableData implements SS_List, Filterable, Sortable, Li
*/
public function removeAll()
{
foreach ($this->getGenerator() as $item) {
foreach ($this as $item) {
$this->remove($item);
}
return $this;