public function DefaultParser::parse

Implements \Drupal\aggregator\Plugin\ParserInterface::parse().

Overrides ParserInterface::parse

1 call to DefaultParser::parse()
1 method overrides DefaultParser::parse()

File

drupal/core/modules/aggregator/lib/Drupal/aggregator/Plugin/aggregator/parser/DefaultParser.php, line 73
Contains \Drupal\aggregator\Plugin\aggregator\parser\DefaultParser.

Class

DefaultParser
Defines a default parser implementation.

Namespace

Drupal\aggregator\Plugin\aggregator\parser

Code

public function parse(Feed $feed) {

  // Filter the input data.
  if ($this
    ->parseFeed($feed->source_string, $feed)) {

    // Prepare the channel data.
    foreach ($this->channel as $key => $value) {
      $this->channel[$key] = trim($value);
    }

    // Prepare the image data (if any).
    foreach ($this->image as $key => $value) {
      $this->image[$key] = trim($value);
    }

    // Add parsed data to the feed object.
    $feed->link->value = !empty($channel['link']) ? $channel['link'] : '';
    $feed->description->value = !empty($channel['description']) ? $channel['description'] : '';
    $feed->image->value = !empty($image['url']) ? $image['url'] : '';

    // Clear the page and block caches.
    cache_invalidate_tags(array(
      'content' => TRUE,
    ));
    return TRUE;
  }
  return FALSE;
}