You are here

public function DefaultProcessor::postProcess in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/aggregator/src/Plugin/aggregator/processor/DefaultProcessor.php \Drupal\aggregator\Plugin\aggregator\processor\DefaultProcessor::postProcess()

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

Expires items from a feed depending on expiration settings.

Overrides ProcessorInterface::postProcess

File

core/modules/aggregator/src/Plugin/aggregator/processor/DefaultProcessor.php, line 255

Class

DefaultProcessor
Defines a default processor implementation.

Namespace

Drupal\aggregator\Plugin\aggregator\processor

Code

public function postProcess(FeedInterface $feed) {
  $aggregator_clear = $this->configuration['items']['expire'];
  if ($aggregator_clear != FeedStorageInterface::CLEAR_NEVER) {

    // Delete all items that are older than flush item timer.
    $age = REQUEST_TIME - $aggregator_clear;
    $result = $this->itemStorage
      ->getQuery()
      ->condition('fid', $feed
      ->id())
      ->condition('timestamp', $age, '<')
      ->execute();
    if ($result) {
      $entities = $this->itemStorage
        ->loadMultiple($result);
      $this->itemStorage
        ->delete($entities);
    }
  }
}