dev-master
9999999-devSoft delete extension for SilverStripe
MIT
The Requires
- php >=5.6
- silverstripe/framework ^4.0
by lekoala
module delete silverstripe soft
Soft delete extension for SilverStripe
Add a soft delete behaviour to your dataobjects. Objects are simply marked as deleted and kept in the database., (*1)
Soft delete will follow the same permissions patterns as delete., (*2)
ModelAdmin and SecurityAdmin are extended to add a new GridField action that replace the default delete action, (*3)
This module depends on lekoala/silverstripe-cms-actions for displaying delete buttons, (*4)
Simply replace your calls from delete to softDelete., (*5)
New extensions hooks are provided to avoid side effects (onBeforeSoftDelete, onAfterSoftDelete). These are ideals if you have child records that need to be soft deleted with their parent., (*6)
SilverStripe\Admin\ModelAdmin: softdelete_from_list: true softdelete_from_list_exclude: [] extensions: - SoftDeleteModelAdmin SilverStripe\Admin\SecurityAdmin: softdelete_from_list: true softdelete_from_list_exclude: [] extensions: - SoftDeleteSecurityAdmin
You can configure:, (*7)
By default, the module will prevent any delete from happening. To allow deletion, you must set, (*8)
SoftDeletable:$prevent_delete = false
The only way from the CMS UI to delete a record is to go to a soft deleted record and click "Really delete" which will call "forceDelete" on the record., (*9)
You can disable filtering globally, using, (*10)
SoftDeletable::$disable = true
Or at query level, (*11)
$dataQuery->setQueryParam('SoftDeletable.filter',false)
By default, this module will let you return soft deleted records if you ask them specifically by ID. This is by design to prevent things breaking accidentally. If you want to make sure you don't display soft deleted records, make sure to implement a proper canView() method that fits your usage., (*12)
An alternative option, is to disable that feature:, (*13)
SoftDeletable: check_filters_on_id: false
Keep in mind that DataObject::get_by_id();
can get cached and it can lead to tricky scenarios., (*14)
Tested with 4.4+, (*15)
LeKoala - thomas@lekoala.be, (*16)
Soft delete extension for SilverStripe
MIT
module delete silverstripe soft