From 6ef5b9bcbc270c6afe5326e4c4e80b5c1cdae0c5 Mon Sep 17 00:00:00 2001 From: Thomas Portelange Date: Mon, 14 Aug 2023 09:55:13 +0200 Subject: [PATCH] Make security admin more easily extensible - fix error if import button is missing - fix unhandled match case if model class is not member or group --- code/SecurityAdmin.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/code/SecurityAdmin.php b/code/SecurityAdmin.php index d5ce136b5..f213c8361 100755 --- a/code/SecurityAdmin.php +++ b/code/SecurityAdmin.php @@ -128,11 +128,16 @@ protected function getGridFieldConfig(): GridFieldConfig } /** @var GridFieldImportButton $importButton */ $importButton = $config->getComponentByType(GridFieldImportButton::class); - $modalTitle = match ($this->modelClass) { - Member::class => _t(__CLASS__ . '.IMPORTUSERS', 'Import users'), - Group::class => _t(__CLASS__ . '.IMPORTGROUPS', 'Import groups'), - }; - $importButton->setModalTitle($modalTitle); + if ($importButton) { + $modalTitle = match ($this->modelClass) { + Member::class => _t(__CLASS__ . '.IMPORTUSERS', 'Import users'), + Group::class => _t(__CLASS__ . '.IMPORTGROUPS', 'Import groups'), + default => null, + }; + if ($modalTitle !== null) { + $importButton->setModalTitle($modalTitle); + } + } return $config; }