You are here

protected function AbstractAtom::_setFeedLinks in Zircon Profile 8

Same name in this branch
  1. 8 vendor/zendframework/zend-feed/src/Writer/Renderer/Feed/AbstractAtom.php \Zend\Feed\Writer\Renderer\Feed\AbstractAtom::_setFeedLinks()
  2. 8 vendor/zendframework/zend-feed/src/Writer/Renderer/Feed/Atom/AbstractAtom.php \Zend\Feed\Writer\Renderer\Feed\Atom\AbstractAtom::_setFeedLinks()
Same name and namespace in other branches
  1. 8.0 vendor/zendframework/zend-feed/src/Writer/Renderer/Feed/AbstractAtom.php \Zend\Feed\Writer\Renderer\Feed\AbstractAtom::_setFeedLinks()

Set feed links

Parameters

DOMDocument $dom:

DOMElement $root:

Return value

void

Throws

Writer\Exception\InvalidArgumentException

2 calls to AbstractAtom::_setFeedLinks()
Atom::render in vendor/zendframework/zend-feed/src/Writer/Renderer/Feed/Atom.php
Render Atom feed
AtomSource::render in vendor/zendframework/zend-feed/src/Writer/Renderer/Feed/AtomSource.php
Render Atom Feed Metadata (Source element)

File

vendor/zendframework/zend-feed/src/Writer/Renderer/Feed/AbstractAtom.php, line 180

Class

AbstractAtom

Namespace

Zend\Feed\Writer\Renderer\Feed

Code

protected function _setFeedLinks(DOMDocument $dom, DOMElement $root) {
  $flinks = $this
    ->getDataContainer()
    ->getFeedLinks();
  if (!$flinks || !array_key_exists('atom', $flinks)) {
    $message = 'Atom 1.0 feed elements SHOULD contain one atom:link ' . 'element with a rel attribute value of "self".  This is the ' . 'preferred URI for retrieving Atom Feed Documents representing ' . 'this Atom feed but a feed link has not been set';
    $exception = new Writer\Exception\InvalidArgumentException($message);
    if (!$this->ignoreExceptions) {
      throw $exception;
    }
    else {
      $this->exceptions[] = $exception;
      return;
    }
  }
  foreach ($flinks as $type => $href) {
    $mime = 'application/' . strtolower($type) . '+xml';
    $flink = $dom
      ->createElement('link');
    $root
      ->appendChild($flink);
    $flink
      ->setAttribute('rel', 'self');
    $flink
      ->setAttribute('type', $mime);
    $flink
      ->setAttribute('href', $href);
  }
}