-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
API Delete deprecated canArchive method #460
API Delete deprecated canArchive method #460
Conversation
a3afabb
to
fade1ca
Compare
src/GridFieldArchiveAction.php
Outdated
/* @var DataObject|Versioned $record */ | ||
if (!$record->hasMethod('canArchive') || !$record->canArchive()) { | ||
/** @var ViewableData|Versioned $record */ | ||
if (!$record->has_extension(Versioned::class) || !$record->canDelete()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that the method check used to be there to distinguish between versioned and unversioned records. has_extension()
is the correct way to do that, so we're doing it that way instead.
* @param DataObject $record | ||
* @param ViewableData $record |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
semi-unrelated PHPDoc fix - gridfield can accept any viewable data. This class is used to replace the delete button when versioned is installed, regardless of whether the gridfield in use has dataobjects or not.
fade1ca
to
b8628ef
Compare
For versioned records, there is no concept of "deleting" the record - it's either being archived, unpublished, or in rare cases removed from draft but left published.
Previously the
canDelete()
method has been used to check if a record can be removed from draft specifically for versioned records - which is such a rare edge case it almost doesn't bare thinking about, especially given there's no way to do that purely by interacting with the UI, nor with the web API endpoints available in core or supported modules.Instead,
canDelete()
is now to be used to check if the record can be archived. This reduces cognitive load for developers and is a step towards simplifying the overly-complex versioning system. This is also in keeping with other mechanisms, such ascascade_deletes
which cascades archiving for versioned records.Note that if the record has stages and is published, we don't allow users to archive if they can't unpublish.
Issue
canArchive()
method for CMS 6 #447