public function test() { $file = dirname(dirname(dirname(dirname(dirname(__FILE__))))) . '/tests/resources/opml-example.xml'; $parser = new GenericOpmlParser(file_get_contents($file)); $result = $parser->parse(); $this->assertSame(count($result), 2); $this->assertSame(count($result['head']), 11); $this->assertSame(count($result['outlines']), 11); // Try with lowercase. $result = $parser->parse(TRUE); $this->assertSame(count($result), 2); $this->assertSame(count($result['head']), 11); $this->assertSame(count($result['outlines']), 11); }
/** * {@inheritdoc} */ public function parse(FeedInterface $feed, FetcherResultInterface $fetcher_result, StateInterface $state) { $raw = $fetcher_result->getRaw(); if (!strlen(trim($raw))) { throw new EmptyFeedException(); } $result = new ParserResult(); $parser = new GenericOpmlParser($fetcher_result->getRaw()); $opml = $parser->parse(TRUE); foreach ($this->getItems($opml['outlines']) as $item) { $item->set('feed_title', $opml['head']['#title']); $result->addItem($item); } return $result; }