You are here

protected function Atom::_setAuthors in Zircon Profile 8

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

Set entry authors

Parameters

DOMDocument $dom:

DOMElement $root:

Return value

void

1 call to Atom::_setAuthors()
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 172

Class

Atom

Namespace

Zend\Feed\Writer\Renderer\Entry

Code

protected function _setAuthors(DOMDocument $dom, DOMElement $root) {
  $authors = $this->container
    ->getAuthors();
  if (!$authors || empty($authors)) {

    /**
     * This will actually trigger an Exception at the feed level if
     * a feed level author is not set.
     */
    return;
  }
  foreach ($authors as $data) {
    $author = $this->dom
      ->createElement('author');
    $name = $this->dom
      ->createElement('name');
    $author
      ->appendChild($name);
    $root
      ->appendChild($author);
    $text = $dom
      ->createTextNode($data['name']);
    $name
      ->appendChild($text);
    if (array_key_exists('email', $data)) {
      $email = $this->dom
        ->createElement('email');
      $author
        ->appendChild($email);
      $text = $dom
        ->createTextNode($data['email']);
      $email
        ->appendChild($text);
    }
    if (array_key_exists('uri', $data)) {
      $uri = $this->dom
        ->createElement('uri');
      $author
        ->appendChild($uri);
      $text = $dom
        ->createTextNode($data['uri']);
      $uri
        ->appendChild($text);
    }
  }
}