function DefaultProcessor::postProcess

Same name and namespace in other branches
  1. 8.9.x 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()
            ->accessCheck(FALSE)
            ->condition('fid', $feed->id())
            ->condition('timestamp', $age, '<')
            ->execute();
        if ($result) {
            $entities = $this->itemStorage
                ->loadMultiple($result);
            $this->itemStorage
                ->delete($entities);
        }
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.