Skip to content

Commit

Permalink
API Update method signature for CMSEditLink (#463)
Browse files Browse the repository at this point in the history
  • Loading branch information
GuySartorelli authored Aug 25, 2024
1 parent f192c07 commit eab840e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
12 changes: 2 additions & 10 deletions src/ChangeSetItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/RestoreAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -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('<a href="%s">%s</a>', $restoredItem->CMSEditLink(), $restoredID);
$editLink = $restoredItem->CMSEditLink();
if ($editLink) {
$restoredID = sprintf('<a href="%s">%s</a>', $editLink, $restoredID);
}

if ($originalItem->URLSegment !== $restoredItem->URLSegment) {
Expand Down

0 comments on commit eab840e

Please sign in to comment.