Beispiel #1
0
 public function testFindLinkXml()
 {
     $xml = '<feed xmlns="http://www.w3.org/2005/Atom">
         <title>Blah blah blah</title>
         <link href="http://example.com/feed" rel="self" type="application/atom+xml"/>
         <link href="http://example.com" rel="alternate" type="text/html"/>
         <link rel="hub" href="http://example.com/hub" />
         <updated>2015-02-03T13:08:02+01:00</updated>
         <id>http://blog.superfeedr.com/</id></feed>';
     $this->assertSame('http://example.com/hub', HttpHelpers::findRelationFromXml($xml, 'hub'));
     $xml = '<?xml version="1.0"?>
         <rss xmlns:atom="http://www.w3.org/2005/Atom">
         <channel>
         <atom:link rel="hub" href="http://example.com/hub"/>
         </channel></rss>';
     $this->assertSame('http://example.com/hub', HttpHelpers::findRelationFromXml($xml, 'hub'));
     $this->assertSame(FALSE, HttpHelpers::findRelationFromXml('', 'hub'));
     $this->assertSame(FALSE, HttpHelpers::findRelationFromXml(' ', 'hub'));
 }
Beispiel #2
0
 /**
  * Finds a hub from a fetcher result.
  *
  * @param \Drupal\feeds\Result\FetcherResultInterface $fetcher_result
  *   The fetcher result.
  *
  * @return string|null
  *   The hub URL or null if one wasn't found.
  */
 protected function findRelation(FetcherResultInterface $fetcher_result, $relation)
 {
     if ($fetcher_result instanceof HttpFetcherResultInterface) {
         if ($rel = HttpHelpers::findLinkHeader($fetcher_result->getHeaders(), $relation)) {
             return $rel;
         }
     }
     return HttpHelpers::findRelationFromXml($fetcher_result->getRaw(), $relation);
 }