fix: [CRUD] delete post message fix
- correct order of execution for the beforesave commandpull/92/head
parent
0e427e97c9
commit
eae8e62e5e
|
@ -467,15 +467,10 @@ class CRUDComponent extends Component
|
||||||
if (!empty($params['contain'])) {
|
if (!empty($params['contain'])) {
|
||||||
$data->contain($params['contain']);
|
$data->contain($params['contain']);
|
||||||
}
|
}
|
||||||
|
$data = $data->first();
|
||||||
if (isset($params['beforeSave'])) {
|
if (isset($params['beforeSave'])) {
|
||||||
$data = $params['beforeSave']($data);
|
$data = $params['beforeSave']($data);
|
||||||
if ($data === false) {
|
|
||||||
$skipExecution = true;
|
|
||||||
$success = false;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (!$skipExecution) {
|
|
||||||
$data = $data->first();
|
|
||||||
if (!empty($data)) {
|
if (!empty($data)) {
|
||||||
$success = $this->Table->delete($data);
|
$success = $this->Table->delete($data);
|
||||||
$success = true;
|
$success = true;
|
||||||
|
@ -486,7 +481,6 @@ class CRUDComponent extends Component
|
||||||
$bulkSuccesses++;
|
$bulkSuccesses++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
$message = $this->getMessageBasedOnResult(
|
$message = $this->getMessageBasedOnResult(
|
||||||
$bulkSuccesses == count($ids),
|
$bulkSuccesses == count($ids),
|
||||||
$isBulk,
|
$isBulk,
|
||||||
|
|
Loading…
Reference in New Issue