public function DefaultProcessor::postProcess

Implements \Drupal\aggregator\Plugin\ProcessorInterface::postProcess().

Expires items from a feed depending on expiration settings.

Overrides ProcessorInterface::postProcess

File

drupal/core/modules/aggregator/lib/Drupal/aggregator/Plugin/aggregator/processor/DefaultProcessor.php, line 166
Contains \Drupal\aggregator\Plugin\aggregator\processor\DefaultProcessor.

Class

DefaultProcessor
Defines a default processor implementation.

Namespace

Drupal\aggregator\Plugin\aggregator\processor

Code

public function postProcess(Feed $feed) {
  $aggregator_clear = config('aggregator.settings')
    ->get('items.expire');
  if ($aggregator_clear != AGGREGATOR_CLEAR_NEVER) {

    // Remove all items that are older than flush item timer.
    $age = REQUEST_TIME - $aggregator_clear;
    $iids = Database::getConnection()
      ->query('SELECT iid FROM {aggregator_item} WHERE fid = :fid AND timestamp < :timestamp', array(
      ':fid' => $feed
        ->id(),
      ':timestamp' => $age,
    ))
      ->fetchCol();
    if ($iids) {
      entity_delete_multiple('aggregator_item', $iids);
    }
  }
}