Skip to content

Commit

Permalink
FIX Set the CSV importer based on the tab, not the model (#1676)
Browse files Browse the repository at this point in the history
  • Loading branch information
GuySartorelli authored Feb 8, 2024
1 parent b4f13ed commit 8a3833e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion code/ModelAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -621,14 +621,15 @@ public function getModelImporters()

$importers = [];
foreach ($importerClasses as $modelClass => $importerClass) {
$tab = $modelClass;
if (isset($models[$modelClass])) {
$modelClass = $models[$modelClass]['dataClass'];
}
$importer = new $importerClass($modelClass);
if (ClassInfo::hasMethod($importer, 'setCheckPermissions')) {
$importer->setCheckPermissions(true);
}
$importers[$modelClass] = $importer;
$importers[$tab] = $importer;
}

return $importers;
Expand Down
4 changes: 3 additions & 1 deletion tests/php/ModelAdminTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,11 @@ public function testGetModelImporters()
{
$admin = new ModelAdminTest\MultiModelAdmin();
$importers = $admin->getModelImporters();
$this->assertCount(2, $importers);
$this->assertCount(4, $importers);
$this->assertArrayHasKey(Contact::class, $importers);
$this->assertArrayHasKey(Player::class, $importers);
$this->assertArrayHasKey('Player', $importers);
$this->assertArrayHasKey('cricket-players', $importers);
}

public function testGetManagedModels()
Expand Down

0 comments on commit 8a3833e

Please sign in to comment.