You are here

public function Feed::getItunesCategories in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/zendframework/zend-feed/src/Reader/Extension/Podcast/Feed.php \Zend\Feed\Reader\Extension\Podcast\Feed::getItunesCategories()

Get the entry category

Return value

array|null

File

vendor/zendframework/zend-feed/src/Reader/Extension/Podcast/Feed.php, line 68

Class

Feed

Namespace

Zend\Feed\Reader\Extension\Podcast

Code

public function getItunesCategories() {
  if (isset($this->data['categories'])) {
    return $this->data['categories'];
  }
  $categoryList = $this->xpath
    ->query($this
    ->getXpathPrefix() . '/itunes:category');
  $categories = [];
  if ($categoryList->length > 0) {
    foreach ($categoryList as $node) {
      $children = null;
      if ($node->childNodes->length > 0) {
        $children = [];
        foreach ($node->childNodes as $childNode) {
          if (!$childNode instanceof DOMText) {
            $children[$childNode
              ->getAttribute('text')] = null;
          }
        }
      }
      $categories[$node
        ->getAttribute('text')] = $children;
    }
  }
  if (!$categories) {
    $categories = null;
  }
  $this->data['categories'] = $categories;
  return $this->data['categories'];
}