From eab840e0256d47c9172c08d9332376592a98ae4d Mon Sep 17 00:00:00 2001 From: Guy Sartorelli <36352093+GuySartorelli@users.noreply.github.com> Date: Mon, 26 Aug 2024 09:58:28 +1200 Subject: [PATCH] API Update method signature for CMSEditLink (#463) --- src/ChangeSetItem.php | 12 ++---------- src/RestoreAction.php | 6 +++--- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/src/ChangeSetItem.php b/src/ChangeSetItem.php index 6811a783..2a1b0880 100644 --- a/src/ChangeSetItem.php +++ b/src/ChangeSetItem.php @@ -531,18 +531,10 @@ public function getPreviewLinks() return $links; } - /** - * Get edit link for this item - * - * @return string - */ - public function CMSEditLink() + public function CMSEditLink(): ?string { $link = $this->getObjectInStage(Versioned::DRAFT); - if ($link instanceof CMSPreviewable) { - return $link->CMSEditLink(); - } - return null; + return $link->CMSEditLink(); } /** diff --git a/src/RestoreAction.php b/src/RestoreAction.php index a9739edc..678cb6ba 100644 --- a/src/RestoreAction.php +++ b/src/RestoreAction.php @@ -88,9 +88,9 @@ public static function getRestoreMessage($originalItem, $restoredItem, $changedL $restoredID = $restoredItem->Title ?: $restoredItem->ID; $restoredType = strtolower($restoredItem->i18n_singular_name() ?? ''); - if (method_exists($restoredItem, 'CMSEditLink') && - $restoredItem->CMSEditLink()) { - $restoredID = sprintf('%s', $restoredItem->CMSEditLink(), $restoredID); + $editLink = $restoredItem->CMSEditLink(); + if ($editLink) { + $restoredID = sprintf('%s', $editLink, $restoredID); } if ($originalItem->URLSegment !== $restoredItem->URLSegment) {