FIX Ensure unstaged versioned objects can be previewed.

This commit is contained in:
Guy Sartorelli 2022-05-06 14:30:01 +12:00
parent 3a990c95f5
commit 83104da329
1 changed files with 13 additions and 1 deletions

View File

@ -40,12 +40,24 @@ class SilverStripeNavigatorItem_Unversioned extends SilverStripeNavigatorItem
public function canView($member = null)
{
return (
!$this->getRecord()->hasExtension(Versioned::class)
$this->recordIsUnversioned()
&& $this->showUnversionedLink()
&& $this->getLink()
);
}
private function recordIsUnversioned(): bool
{
$record = $this->getRecord();
// If the record has the Versioned extension, it can be considered unversioned
// for the purposes of this class if it has no stages and is not archived.
if ($record->hasExtension(Versioned::class)) {
return (!$record->hasStages()) && !$this->isArchived();
}
// Completely unversioned.
return true;
}
/**
* True if the record is configured to display this item.
*