mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-09-18 07:26:40 +02: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
|
// Remove limit as the list may be paginated, we want the full list for the export
|
||||||
$items = $items->limit(null);
|
$items = $items->limit(null);
|
||||||
// Use Generator in applicable cases to reduce memory consumption
|
|
||||||
$items = $items instanceof DataList
|
|
||||||
? $items->getGenerator()
|
|
||||||
: $items;
|
|
||||||
|
|
||||||
/** @var DataObject $item */
|
/** @var DataObject $item */
|
||||||
foreach ($items as $item) {
|
foreach ($items as $item) {
|
||||||
|
@ -790,20 +790,6 @@ 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>";
|
||||||
@ -1214,7 +1200,7 @@ class DataList extends ViewableData implements SS_List, Filterable, Sortable, Li
|
|||||||
*/
|
*/
|
||||||
public function removeAll()
|
public function removeAll()
|
||||||
{
|
{
|
||||||
foreach ($this->getGenerator() as $item) {
|
foreach ($this as $item) {
|
||||||
$this->remove($item);
|
$this->remove($item);
|
||||||
}
|
}
|
||||||
return $this;
|
return $this;
|
||||||
|
Loading…
Reference in New Issue
Block a user