/**
  * Implements \Drupal\aggregator\Plugin\ProcessorInterface::postProcess().
  *
  * Expires items from a feed depending on expiration settings.
  */
 public function postProcess(FeedInterface $feed)
 {
     $aggregator_clear = $this->configuration['items']['expire'];
     if ($aggregator_clear != AGGREGATOR_CLEAR_NEVER) {
         // Delete all items that are older than flush item timer.
         $age = REQUEST_TIME - $aggregator_clear;
         $result = $this->itemQuery->condition('fid', $feed->id())->condition('timestamp', $age, '<')->execute();
         if ($result) {
             $entities = $this->itemStorage->loadMultiple($result);
             $this->itemStorage->delete($entities);
         }
     }
 }
 /**
  * {@inheritdoc}
  */
 public function build()
 {
     // Load the selected feed.
     if ($feed = $this->feedStorage->load($this->configuration['feed'])) {
         $result = $this->itemQuery->condition('fid', $feed->id())->range(0, $this->configuration['block_count'])->sort('timestamp', 'DESC')->sort('iid', 'DESC')->execute();
         if ($result) {
             // Only display the block if there are items to show.
             $items = $this->itemStorage->loadMultiple($result);
             $build['list'] = ['#theme' => 'item_list', '#items' => []];
             foreach ($items as $item) {
                 $build['list']['#items'][$item->id()] = ['#type' => 'link', '#url' => $item->urlInfo(), '#title' => $item->label()];
             }
             $build['more_link'] = ['#type' => 'more_link', '#url' => $feed->urlInfo(), '#attributes' => ['title' => $this->t("View this feed's recent news.")]];
             return $build;
         }
     }
 }
 /**
  * {@inheritdoc}
  */
 public function build()
 {
     // Load the selected feed.
     if ($feed = $this->feedStorage->load($this->configuration['feed'])) {
         $result = $this->itemQuery->condition('fid', $feed->id())->range(0, $this->configuration['block_count'])->sort('timestamp', 'DESC')->sort('iid', 'DESC')->execute();
         $items = $this->itemStorage->loadMultiple($result);
         $more_link = array('#theme' => 'more_link', '#url' => 'aggregator/sources/' . $feed->id(), '#title' => t("View this feed's recent news."));
         $read_more = drupal_render($more_link);
         $rendered_items = array();
         foreach ($items as $item) {
             $aggregator_block_item = array('#theme' => 'aggregator_block_item', '#item' => $item);
             $rendered_items[] = drupal_render($aggregator_block_item);
         }
         // Only display the block if there are items to show.
         if (count($rendered_items) > 0) {
             $item_list = array('#theme' => 'item_list', '#items' => $rendered_items);
             return array('#children' => drupal_render($item_list) . $read_more);
         }
     }
 }