You are here

protected function Feed::_setCategories in Zircon Profile 8

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

Set feed categories

Parameters

DOMDocument $dom:

DOMElement $root:

Return value

void

1 call to Feed::_setCategories()
Feed::render in vendor/zendframework/zend-feed/src/Writer/Extension/ITunes/Renderer/Feed.php
Render feed

File

vendor/zendframework/zend-feed/src/Writer/Extension/ITunes/Renderer/Feed.php, line 112

Class

Feed

Namespace

Zend\Feed\Writer\Extension\ITunes\Renderer

Code

protected function _setCategories(DOMDocument $dom, DOMElement $root) {
  $cats = $this
    ->getDataContainer()
    ->getItunesCategories();
  if (!$cats || empty($cats)) {
    return;
  }
  foreach ($cats as $key => $cat) {
    if (!is_array($cat)) {
      $el = $dom
        ->createElement('itunes:category');
      $el
        ->setAttribute('text', $cat);
      $root
        ->appendChild($el);
    }
    else {
      $el = $dom
        ->createElement('itunes:category');
      $el
        ->setAttribute('text', $key);
      $root
        ->appendChild($el);
      foreach ($cat as $subcat) {
        $el2 = $dom
          ->createElement('itunes:category');
        $el2
          ->setAttribute('text', $subcat);
        $el
          ->appendChild($el2);
      }
    }
  }
  $this->called = true;
}