You are here

protected function CiviEntityStorage::doDelete in CiviCRM Entity 8.3

Performs storage-specific entity deletion.

Parameters

\Drupal\Core\Entity\EntityInterface[] $entities: An array of entity objects to delete.

Overrides ContentEntityStorageBase::doDelete

File

src/CiviEntityStorage.php, line 95

Class

CiviEntityStorage
Defines entity class for external CiviCRM entities.

Namespace

Drupal\civicrm_entity

Code

protected function doDelete($entities) {

  /** @var \Drupal\Core\Entity\EntityInterface $entity */
  foreach ($entities as $entity) {
    try {
      $params['id'] = $entity
        ->id();
      $this
        ->getCiviCrmApi()
        ->delete($this->entityType
        ->get('civicrm_entity'), $params);
    } catch (\Exception $e) {
      throw $e;
    }
  }
  $this
    ->doDeleteFieldItems($entities);
}