You are here

protected function Rss::_setLink in Zircon Profile 8

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

Set link to feed

Parameters

DOMDocument $dom:

DOMElement $root:

Return value

void

Throws

Writer\Exception\InvalidArgumentException

1 call to Rss::_setLink()
Rss::render in vendor/zendframework/zend-feed/src/Writer/Renderer/Feed/Rss.php
Render RSS feed

File

vendor/zendframework/zend-feed/src/Writer/Renderer/Feed/Rss.php, line 228

Class

Rss

Namespace

Zend\Feed\Writer\Renderer\Feed

Code

protected function _setLink(DOMDocument $dom, DOMElement $root) {
  $value = $this
    ->getDataContainer()
    ->getLink();
  if (!$value) {
    $message = 'RSS 2.0 feed elements MUST contain exactly one' . ' link element but one has not been set';
    $exception = new Writer\Exception\InvalidArgumentException($message);
    if (!$this->ignoreExceptions) {
      throw $exception;
    }
    else {
      $this->exceptions[] = $exception;
      return;
    }
  }
  $link = $dom
    ->createElement('link');
  $root
    ->appendChild($link);
  $text = $dom
    ->createTextNode($value);
  $link
    ->appendChild($text);
  if (!Uri::factory($value)
    ->isValid()) {
    $link
      ->setAttribute('isPermaLink', 'false');
  }
}