Skip to content

Commit

Permalink
refactor duplicated lines
Browse files Browse the repository at this point in the history
  • Loading branch information
lekoala committed May 10, 2024
1 parent 60f5dd5 commit 54716a4
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/ActionsGridFieldItemRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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");
}
Expand Down

0 comments on commit 54716a4

Please sign in to comment.