You are here

public function SpoolStorage::clear in Simplenews 8

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

Remove old records from mail spool table.

All records with status 'send' and time stamp before the expiration date are removed from the spool.

Return value

int Number of deleted spool rows.

Overrides SpoolStorageInterface::clear

File

src/Spool/SpoolStorage.php, line 203

Class

SpoolStorage
Default database spool storage.

Namespace

Drupal\simplenews\Spool

Code

public function clear() {
  $expiration_time = REQUEST_TIME - $this->config
    ->get('mail.spool_expire') * 86400;
  return $this->connection
    ->delete('simplenews_mail_spool')
    ->condition('status', [
    SpoolStorageInterface::STATUS_DONE,
    SpoolStorageInterface::STATUS_SKIPPED,
  ], 'IN')
    ->condition('timestamp', $expiration_time, '<=')
    ->execute();
}