Skip to content

Commit

Permalink
allow yml for export limit
Browse files Browse the repository at this point in the history
  • Loading branch information
lekoala committed May 2, 2024
1 parent c6452ef commit 16bee2a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/ExcelGridFieldExportButton.php
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,10 @@ public function generateExportFileData($gridField)

$list = $items;
if ($items instanceof DataList) {
$list = $items->limit(ExcelImportExport::$limit_exports);
$limit = ExcelImportExport::getExportLimit();
if ($limit && $limit > 0) {
$list = $items->limit($limit);
}
if (!empty($this->listFilters)) {
$list = $list->filter($this->listFilters);
}
Expand Down
13 changes: 13 additions & 0 deletions src/ExcelImportExport.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,19 @@ class ExcelImportExport
*/
public static $limit_exports = 1000;

/**
* You can override the static var with yml config if needed
* @return int
*/
public static function getExportLimit()
{
$v = self::config()->export_limit;
if ($v) {
return $v;
}
return self::$limit_exports;
}

/**
* Get all db fields for a given dataobject class
*
Expand Down

0 comments on commit 16bee2a

Please sign in to comment.