You are here

protected function Atom::_setCategories 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::_setCategories()

Set entry categories

Parameters

DOMDocument $dom:

DOMElement $root:

Return value

void

1 call to Atom::_setCategories()
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 394

Class

Atom

Namespace

Zend\Feed\Writer\Renderer\Entry

Code

protected function _setCategories(DOMDocument $dom, DOMElement $root) {
  $categories = $this
    ->getDataContainer()
    ->getCategories();
  if (!$categories) {
    return;
  }
  foreach ($categories as $cat) {
    $category = $dom
      ->createElement('category');
    $category
      ->setAttribute('term', $cat['term']);
    if (isset($cat['label'])) {
      $category
        ->setAttribute('label', $cat['label']);
    }
    else {
      $category
        ->setAttribute('label', $cat['term']);
    }
    if (isset($cat['scheme'])) {
      $category
        ->setAttribute('scheme', $cat['scheme']);
    }
    $root
      ->appendChild($category);
  }
}