You are here

public static function CartStorage::delete in Basic cart 8.6

Same name and namespace in other branches
  1. 8 src/CartStorage.php \Drupal\basic_cart\CartStorage::delete()
  2. 8.0 src/CartStorage.php \Drupal\basic_cart\CartStorage::delete()
  3. 8.2 src/CartStorage.php \Drupal\basic_cart\CartStorage::delete()
  4. 8.3 src/CartStorage.php \Drupal\basic_cart\CartStorage::delete()
  5. 8.4 src/CartStorage.php \Drupal\basic_cart\CartStorage::delete()
  6. 8.5 src/CartStorage.php \Drupal\basic_cart\CartStorage::delete()

Delete a cart entry from the database.

Parameters

array $entry: An array containing at least the person identifier 'pid' element of the entry to delete.

See also

db_delete()

File

src/CartStorage.php, line 87

Class

CartStorage
Class CartStorage.

Namespace

Drupal\basic_cart

Code

public static function delete(array $entry) {

  // TODO: Drupal Rector Notice: Please delete the following comment after you've made any necessary changes.
  // You will need to use `\Drupal\core\Database\Database::getConnection()` if you do not yet have access to the container here.
  $delete = \Drupal::database()
    ->delete(self::TABLE);
  if ($entry['uid']) {
    $delete
      ->condition('uid', $entry['uid']);
  }
  if ($entry['id']) {
    $delete
      ->condition('id', $entry['id']);
    $delete
      ->condition('entitytype', $entry['entitytype'] ? $entry['entitytype'] : 'node');
  }
  $delete
    ->execute();
}