You are here

public function SpoolStorage::deleteMails in Simplenews 8

Same name and namespace in other branches
  1. 8.2 src/Spool/SpoolStorage.php \Drupal\simplenews\Spool\SpoolStorage::deleteMails()
  2. 3.x src/Spool/SpoolStorage.php \Drupal\simplenews\Spool\SpoolStorage::deleteMails()

Remove records from mail spool table according to the conditions.

Return value

int Count deleted

Overrides SpoolStorageInterface::deleteMails

File

src/Spool/SpoolStorage.php, line 215

Class

SpoolStorage
Default database spool storage.

Namespace

Drupal\simplenews\Spool

Code

public function deleteMails(array $conditions) {

  // Continue to support 'nid'.
  if (!empty($conditions['nid'])) {
    $conditions['entity_type'] = 'node';
    $conditions['entity_id'] = $conditions['nid'];
    unset($conditions['nid']);
  }
  $query = $this->connection
    ->delete('simplenews_mail_spool');
  foreach ($conditions as $condition => $value) {
    $query
      ->condition($condition, $value);
  }
  return $query
    ->execute();
}