From 54716a47f7fddd61d7353897fd1fe17387c92fd6 Mon Sep 17 00:00:00 2001 From: Thomas Date: Fri, 10 May 2024 15:47:30 +0200 Subject: [PATCH] refactor duplicated lines --- src/ActionsGridFieldItemRequest.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/ActionsGridFieldItemRequest.php b/src/ActionsGridFieldItemRequest.php index e53f4b0..e64a2f1 100644 --- a/src/ActionsGridFieldItemRequest.php +++ b/src/ActionsGridFieldItemRequest.php @@ -798,12 +798,13 @@ public function doSaveAndNext($data, $form) $controller = $this->getToplevelController(); $controller->getResponse()->addHeader("X-Pjax", "Content"); - $class = get_class($record); - $getNextRecordID = $this->getCustomNextRecordID($record); $class = get_class($record); if (!$class) { throw new Exception("Could not get class"); } + + $getNextRecordID = $this->getCustomNextRecordID($record); + /** @var ?DataObject $next */ $next = $class::get()->byID($getNextRecordID); @@ -837,8 +838,11 @@ public function doSaveAndPrev($data, $form) $controller->getResponse()->addHeader("X-Pjax", "Content"); $class = get_class($record); + if (!$class) { + throw new Exception("Could not get class"); + } + $getPreviousRecordID = $this->getCustomPreviousRecordID($record); - $class = get_class($record); if (!$class) { throw new Exception("Could not get class"); }