Skip to content

Commit 14007e3

Browse files
committed
adjust new handler
1 parent 11191d1 commit 14007e3

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/ExcelImportExport.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
use PhpOffice\PhpSpreadsheet\Reader\IReader;
2222
use PhpOffice\PhpSpreadsheet\Writer\IWriter;
2323
use SilverStripe\Assets\FileNameFilter;
24-
use SilverStripe\Core\Injector\Injector;
2524

2625
/**
2726
* Support class for the module
@@ -270,7 +269,9 @@ public static function useCustomHandler($handler, Form $form, Controller $contro
270269
$file = $_FILES['_CsvFile']['tmp_name'];
271270
$name = $_FILES['_CsvFile']['name'];
272271

273-
$inst = new $handler($form, $controller);
272+
// Handler could be any class with a ::load method or an instance of BulkLoader
273+
$modelClass = method_exists($handler, 'getModelClass') ? $controller->getModelClass() : null;
274+
$inst = new $handler($modelClass);
274275

275276
if (!empty($_POST['OnlyUpdateRecords']) && method_exists($inst, 'setOnlyUpdate')) {
276277
$inst->setOnlyUpdate(true);

0 commit comments

Comments
 (0)