You are here

public function FeedsSyndicationParser::parse in Feeds 8.2

Implements FeedsParser::parse().

Overrides FeedsParser::parse

File

lib/Drupal/feeds/Plugin/feeds/parser/FeedsSyndicationParser.php, line 31
Contains \Drupal\feeds\Plugin\feeds\parser\FeedsSyndicationParser.

Class

FeedsSyndicationParser
Defines an RSS and Atom feed parser.

Namespace

Drupal\feeds\Plugin\feeds\parser

Code

public function parse(FeedsSource $source, FeedsFetcherResult $fetcher_result) {
  feeds_include_library('common_syndication_parser.inc', 'common_syndication_parser');
  $feed = common_syndication_parser_parse($fetcher_result
    ->getRaw());
  $result = new FeedsParserResult();
  $result->title = $feed['title'];
  $result->description = $feed['description'];
  $result->link = $feed['link'];
  if (is_array($feed['items'])) {
    foreach ($feed['items'] as $item) {
      if (isset($item['geolocations'])) {
        foreach ($item['geolocations'] as $k => $v) {
          $item['geolocations'][$k] = new FeedsGeoTermElement($v);
        }
      }
      $result->items[] = $item;
    }
  }
  return $result;
}