X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=Civi%2FApi4%2FGeneric%2FDAODeleteAction.php;h=666e702993a1e78823cc90d769c291480f68e12f;hb=961e974cb7faf9f3d43482747b32cb94661f21a9;hp=3e0135f8991cbcb291f5aaf1c9f625edebba5417;hpb=2d82d5a2151b9e9ac865f223521836ea4d530566;p=civicrm-core.git diff --git a/Civi/Api4/Generic/DAODeleteAction.php b/Civi/Api4/Generic/DAODeleteAction.php index 3e0135f899..666e702993 100644 --- a/Civi/Api4/Generic/DAODeleteAction.php +++ b/Civi/Api4/Generic/DAODeleteAction.php @@ -38,7 +38,7 @@ class DAODeleteAction extends AbstractBatchAction { throw new \API_Exception('Cannot delete ' . $this->getEntityName() . ' with no "where" parameter specified'); } - $items = $this->getObjects(); + $items = $this->getBatchRecords(); if ($items) { $result->exchangeArray($this->deleteObjects($items)); } @@ -54,8 +54,9 @@ class DAODeleteAction extends AbstractBatchAction { $baoName = $this->getBaoName(); if ($this->getCheckPermissions()) { - foreach ($items as $item) { - $this->checkContactPermissions($baoName, $item); + foreach (array_keys($items) as $key) { + $items[$key]['check_permissions'] = TRUE; + $this->checkContactPermissions($baoName, $items[$key]); } } @@ -73,16 +74,8 @@ class DAODeleteAction extends AbstractBatchAction { } else { foreach ($items as $item) { - $bao = new $baoName(); - $bao->id = $item['id']; - // delete it - $action_result = $bao->delete(); - if ($action_result) { - $ids[] = ['id' => $item['id']]; - } - else { - throw new \API_Exception("Could not delete {$this->getEntityName()} id {$item['id']}"); - } + $baoName::deleteRecord($item); + $ids[] = ['id' => $item['id']]; } } return $ids;