Skip to content

Commit

Permalink
API Remove unnecessary getGenerator() method.
Browse files Browse the repository at this point in the history
`getIterator()` now returns a generator by default.
  • Loading branch information
GuySartorelli committed Aug 11, 2022
1 parent be98365 commit 2cd2dd1
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 19 deletions.
4 changes: 0 additions & 4 deletions src/Forms/GridField/GridFieldExportButton.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,6 @@ public function generateExportFileData($gridField)

// 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) {
Expand Down
16 changes: 1 addition & 15 deletions src/ORM/DataList.php
Original file line number Diff line number Diff line change
Expand Up @@ -791,20 +791,6 @@ public function each($callback)
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>";
Expand Down Expand Up @@ -1206,7 +1192,7 @@ public function shuffle()
*/
public function removeAll()
{
foreach ($this->getGenerator() as $item) {
foreach ($this as $item) {
$this->remove($item);
}
return $this;
Expand Down

0 comments on commit 2cd2dd1

Please sign in to comment.