You are here

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

Set feed title

Parameters

DOMDocument $dom:

DOMElement $root:

Return value

void

Throws

Writer\Exception\InvalidArgumentException

2 calls to AbstractAtom::_setTitle()
Atom::render in vendor/zendframework/zend-feed/src/Writer/Renderer/Feed/Atom.php
Render Atom feed
AtomSource::render in vendor/zendframework/zend-feed/src/Writer/Renderer/Feed/AtomSource.php
Render Atom Feed Metadata (Source element)

File

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

Class

AbstractAtom

Namespace

Zend\Feed\Writer\Renderer\Feed

Code

protected function _setTitle(DOMDocument $dom, DOMElement $root) {
  if (!$this
    ->getDataContainer()
    ->getTitle()) {
    $message = 'Atom 1.0 feed elements MUST contain exactly one' . ' atom:title element but a title has not been set';
    $exception = new Writer\Exception\InvalidArgumentException($message);
    if (!$this->ignoreExceptions) {
      throw $exception;
    }
    else {
      $this->exceptions[] = $exception;
      return;
    }
  }
  $title = $dom
    ->createElement('title');
  $root
    ->appendChild($title);
  $title
    ->setAttribute('type', 'text');
  $text = $dom
    ->createTextNode($this
    ->getDataContainer()
    ->getTitle());
  $title
    ->appendChild($text);
}