Make delete handler respect `canDelete`

This commit is contained in:
Rob Ingram 2017-06-29 11:52:10 +12:00
parent 3aad957a69
commit f0b007ca09
1 changed files with 6 additions and 4 deletions

View File

@ -1,7 +1,7 @@
<?php
/**
* Bulk action handler for deleting records.
*
*
* @author colymba
*/
class GridFieldBulkActionDeleteHandler extends GridFieldBulkActionHandler
@ -24,7 +24,7 @@ class GridFieldBulkActionDeleteHandler extends GridFieldBulkActionHandler
/**
* Delete the selected records passed from the delete bulk action.
*
*
* @param SS_HTTPRequest $request
*
* @return SS_HTTPResponse List of deleted records ID
@ -34,8 +34,10 @@ class GridFieldBulkActionDeleteHandler extends GridFieldBulkActionHandler
$ids = array();
foreach ($this->getRecords() as $record) {
array_push($ids, $record->ID);
$record->delete();
if ($record->canDelete()) {
array_push($ids, $record->ID);
$record->delete();
}
}
$response = new SS_HTTPResponse(Convert::raw2json(array(