You are here

protected function AbstractAtom::_setCategories in Zircon Profile 8.0

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

Set feed categories

Parameters

DOMDocument $dom:

DOMElement $root:

Return value

void

1 call to AbstractAtom::_setCategories()
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 379

Class

AbstractAtom

Namespace

Zend\Feed\Writer\Renderer\Feed\Atom

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);
  }
}