You are here

public function AssetFeedsProcessor::expire in Asset 7

Implement expire().

File

modules/asset_feeds/AssetFeedsProcessor.inc, line 83
Class definition of AssetFeedsProcessor.

Class

AssetFeedsProcessor
Creates assets from feed items.

Code

public function expire($time = NULL) {
  if ($time === NULL) {
    $time = $this
      ->expiryTime();
  }
  if ($time == FEEDS_EXPIRE_NEVER) {
    return;
  }
  $count = $this
    ->getLimit();
  $assets = db_query_range("SELECT a.aid FROM {asset} a JOIN {feeds_item} fi ON fi.entity_type = 'asset' AND a.aid = fi.entity_id WHERE fi.id = :id AND a.created < :created", 0, $count, array(
    ':id' => $this->id,
    ':created' => REQUEST_TIME - $time,
  ));
  $aids = array();
  foreach ($assets as $asset) {
    $aids[$asset->aid] = $asset->aid;
  }
  $this
    ->entityDeleteMultiple($aids);
  if (db_query_range("SELECT 1 FROM {asset} a JOIN {feeds_item} fi ON fi.entity_type = 'asset' AND a.aid = fi.entity_id WHERE fi.id = :id AND a.created < :created", 0, 1, array(
    ':id' => $this->id,
    ':created' => REQUEST_TIME - $time,
  ))
    ->fetchField()) {
    return FEEDS_BATCH_ACTIVE;
  }
  return FEEDS_BATCH_COMPLETE;
}