public function SqlContentEntityStorage::delete

public SqlContentEntityStorage::delete(array $entities)

Deletes permanently saved entities.

Parameters

array $entities: An array of entity objects to delete.

Throws

\Drupal\Core\Entity\EntityStorageException In case of failures, an exception is thrown.

Overrides EntityStorageBase::delete

File

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

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;
  }

  $transaction = $this->database->startTransaction();
  try {
    parent::delete($entities);

    // Ignore replica server temporarily.
    db_ignore_replica();
  }
  catch (\Exception $e) {
    $transaction->rollback();
    watchdog_exception($this->entityTypeId, $e);
    throw new EntityStorageException($e->getMessage(), $e->getCode(), $e);
  }
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Entity!Sql!SqlContentEntityStorage.php/function/SqlContentEntityStorage::delete/8.1.x