function SqlContentEntityStorage::delete

Same name in other branches
  1. 9 core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php \Drupal\Core\Entity\Sql\SqlContentEntityStorage::delete()
  2. 8.9.x core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php \Drupal\Core\Entity\Sql\SqlContentEntityStorage::delete()
  3. 10 core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php \Drupal\Core\Entity\Sql\SqlContentEntityStorage::delete()

Overrides EntityStorageBase::delete

File

core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php, line 744

Class

SqlContentEntityStorage
A content entity database storage implementation.

Namespace

Drupal\Core\Entity\Sql

Code

public function delete(array $entities) {
    if (!$entities) {
        // If no IDs or invalid IDs were passed, do nothing.
        return;
    }
    try {
        $transaction = $this->database
            ->startTransaction();
        parent::delete($entities);
        // Ignore replica server temporarily.
        \Drupal::service('database.replica_kill_switch')->trigger();
    } catch (\Exception $e) {
        if (isset($transaction)) {
            $transaction->rollBack();
        }
        Error::logException(\Drupal::logger($this->entityTypeId), $e);
        throw new EntityStorageException($e->getMessage(), $e->getCode(), $e);
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.