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));
}
$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]);
}
}
}
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;