You are here

protected function AbstractAtom::_setAuthors 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::_setAuthors()
  2. 8 vendor/zendframework/zend-feed/src/Writer/Renderer/Feed/Atom/AbstractAtom.php \Zend\Feed\Writer\Renderer\Feed\Atom\AbstractAtom::_setAuthors()
Same name and namespace in other branches
  1. 8.0 vendor/zendframework/zend-feed/src/Writer/Renderer/Feed/Atom/AbstractAtom.php \Zend\Feed\Writer\Renderer\Feed\Atom\AbstractAtom::_setAuthors()

Set feed authors

Parameters

DOMDocument $dom:

DOMElement $root:

Return value

void

1 call to AbstractAtom::_setAuthors()
Source::render in vendor/zendframework/zend-feed/src/Writer/Renderer/Feed/Atom/Source.php
Render Atom Feed Metadata (Source element)

File

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

Class

AbstractAtom

Namespace

Zend\Feed\Writer\Renderer\Feed\Atom

Code

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

    /**
     * Technically we should defer an exception until we can check
     * that all entries contain an author. If any entry is missing
     * an author, then a missing feed author element is invalid
     */
    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);
    }
  }
}