mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
API Remove unnecessary getGenerator()
method.
`getIterator()` now returns a generator by default.
This commit is contained in:
parent
bf331072df
commit
a76fa32a39
@ -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) {
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user