You are here

public function Atom::render in Zircon Profile 8.0

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

Render Atom feed

Return value

Atom

File

vendor/zendframework/zend-feed/src/Writer/Renderer/Feed/Atom.php, line 35

Class

Atom

Namespace

Zend\Feed\Writer\Renderer\Feed

Code

public function render() {
  if (!$this->container
    ->getEncoding()) {
    $this->container
      ->setEncoding('UTF-8');
  }
  $this->dom = new DOMDocument('1.0', $this->container
    ->getEncoding());
  $this->dom->formatOutput = true;
  $root = $this->dom
    ->createElementNS(Writer\Writer::NAMESPACE_ATOM_10, 'feed');
  $this
    ->setRootElement($root);
  $this->dom
    ->appendChild($root);
  $this
    ->_setLanguage($this->dom, $root);
  $this
    ->_setBaseUrl($this->dom, $root);
  $this
    ->_setTitle($this->dom, $root);
  $this
    ->_setDescription($this->dom, $root);
  $this
    ->_setImage($this->dom, $root);
  $this
    ->_setDateCreated($this->dom, $root);
  $this
    ->_setDateModified($this->dom, $root);
  $this
    ->_setGenerator($this->dom, $root);
  $this
    ->_setLink($this->dom, $root);
  $this
    ->_setFeedLinks($this->dom, $root);
  $this
    ->_setId($this->dom, $root);
  $this
    ->_setAuthors($this->dom, $root);
  $this
    ->_setCopyright($this->dom, $root);
  $this
    ->_setCategories($this->dom, $root);
  $this
    ->_setHubs($this->dom, $root);
  foreach ($this->extensions as $ext) {
    $ext
      ->setType($this
      ->getType());
    $ext
      ->setRootElement($this
      ->getRootElement());
    $ext
      ->setDOMDocument($this
      ->getDOMDocument(), $root);
    $ext
      ->render();
  }
  foreach ($this->container as $entry) {
    if ($this
      ->getDataContainer()
      ->getEncoding()) {
      $entry
        ->setEncoding($this
        ->getDataContainer()
        ->getEncoding());
    }
    if ($entry instanceof Writer\Entry) {
      $renderer = new Renderer\Entry\Atom($entry);
    }
    else {
      if (!$this->dom->documentElement
        ->hasAttribute('xmlns:at')) {
        $this->dom->documentElement
          ->setAttribute('xmlns:at', 'http://purl.org/atompub/tombstones/1.0');
      }
      $renderer = new Renderer\Entry\AtomDeleted($entry);
    }
    if ($this->ignoreExceptions === true) {
      $renderer
        ->ignoreExceptions();
    }
    $renderer
      ->setType($this
      ->getType());
    $renderer
      ->setRootElement($this->dom->documentElement);
    $renderer
      ->render();
    $element = $renderer
      ->getElement();
    $deep = version_compare(PHP_VERSION, '7', 'ge') ? 1 : true;
    $imported = $this->dom
      ->importNode($element, $deep);
    $root
      ->appendChild($imported);
  }
  return $this;
}