You are here

protected function Atom::_setContent in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/zendframework/zend-feed/src/Writer/Renderer/Entry/Atom.php \Zend\Feed\Writer\Renderer\Entry\Atom::_setContent()

Set entry content

Parameters

DOMDocument $dom:

DOMElement $root:

Return value

void

Throws

Writer\Exception\InvalidArgumentException

1 call to Atom::_setContent()
Atom::render in vendor/zendframework/zend-feed/src/Writer/Renderer/Entry/Atom.php
Render atom entry

File

vendor/zendframework/zend-feed/src/Writer/Renderer/Entry/Atom.php, line 328

Class

Atom

Namespace

Zend\Feed\Writer\Renderer\Entry

Code

protected function _setContent(DOMDocument $dom, DOMElement $root) {
  $content = $this
    ->getDataContainer()
    ->getContent();
  if (!$content && !$this
    ->getDataContainer()
    ->getLink()) {
    $message = 'Atom 1.0 entry elements MUST contain exactly one ' . 'atom:content element, or as an alternative, at least one link ' . 'with a rel attribute of "alternate" to indicate an alternate ' . 'method to consume the content.';
    $exception = new Writer\Exception\InvalidArgumentException($message);
    if (!$this->ignoreExceptions) {
      throw $exception;
    }
    else {
      $this->exceptions[] = $exception;
      return;
    }
  }
  if (!$content) {
    return;
  }
  $element = $dom
    ->createElement('content');
  $element
    ->setAttribute('type', 'xhtml');
  $xhtmlElement = $this
    ->_loadXhtml($content);
  $deep = version_compare(PHP_VERSION, '7', 'ge') ? 1 : true;
  $xhtml = $dom
    ->importNode($xhtmlElement, $deep);
  $element
    ->appendChild($xhtml);
  $root
    ->appendChild($element);
}