You are here

public function FeedSet::addLinks in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/zendframework/zend-feed/src/Reader/FeedSet.php \Zend\Feed\Reader\FeedSet::addLinks()

Import a DOMNodeList from any document containing a set of links for alternate versions of a document, which will normally refer to RSS/RDF/Atom feeds for the current document.

All such links are stored internally, however the first instance of each RSS, RDF or Atom type has its URI stored as a public property as a shortcut where the use case is simply to get a quick feed ref.

Note that feeds are not loaded at this point, but will be lazy loaded automatically when each links 'feed' array key is accessed.

Parameters

DOMNodeList $links:

string $uri:

Return value

void

File

vendor/zendframework/zend-feed/src/Reader/FeedSet.php, line 40

Class

FeedSet

Namespace

Zend\Feed\Reader

Code

public function addLinks(DOMNodeList $links, $uri) {
  foreach ($links as $link) {
    if (strtolower($link
      ->getAttribute('rel')) !== 'alternate' || !$link
      ->getAttribute('type') || !$link
      ->getAttribute('href')) {
      continue;
    }
    if (!isset($this->rss) && $link
      ->getAttribute('type') == 'application/rss+xml') {
      $this->rss = $this
        ->absolutiseUri(trim($link
        ->getAttribute('href')), $uri);
    }
    elseif (!isset($this->atom) && $link
      ->getAttribute('type') == 'application/atom+xml') {
      $this->atom = $this
        ->absolutiseUri(trim($link
        ->getAttribute('href')), $uri);
    }
    elseif (!isset($this->rdf) && $link
      ->getAttribute('type') == 'application/rdf+xml') {
      $this->rdf = $this
        ->absolutiseUri(trim($link
        ->getAttribute('href')), $uri);
    }
    $this[] = new static([
      'rel' => 'alternate',
      'type' => $link
        ->getAttribute('type'),
      'href' => $this
        ->absolutiseUri(trim($link
        ->getAttribute('href')), $uri),
    ]);
  }
}