You are here

public function Feed::getCategories in Zircon Profile 8.0

Same name in this branch
  1. 8.0 vendor/zendframework/zend-feed/src/Reader/Extension/Atom/Feed.php \Zend\Feed\Reader\Extension\Atom\Feed::getCategories()
  2. 8.0 vendor/zendframework/zend-feed/src/Reader/Extension/DublinCore/Feed.php \Zend\Feed\Reader\Extension\DublinCore\Feed::getCategories()
Same name and namespace in other branches
  1. 8 vendor/zendframework/zend-feed/src/Reader/Extension/DublinCore/Feed.php \Zend\Feed\Reader\Extension\DublinCore\Feed::getCategories()

Get categories (subjects under DC)

Return value

Collection\Category

File

vendor/zendframework/zend-feed/src/Reader/Extension/DublinCore/Feed.php, line 237

Class

Feed

Namespace

Zend\Feed\Reader\Extension\DublinCore

Code

public function getCategories() {
  if (array_key_exists('categories', $this->data)) {
    return $this->data['categories'];
  }
  $list = $this
    ->getXpath()
    ->evaluate($this
    ->getXpathPrefix() . '//dc11:subject');
  if (!$list->length) {
    $list = $this
      ->getXpath()
      ->evaluate($this
      ->getXpathPrefix() . '//dc10:subject');
  }
  if ($list->length) {
    $categoryCollection = new Collection\Category();
    foreach ($list as $category) {
      $categoryCollection[] = [
        'term' => $category->nodeValue,
        'scheme' => null,
        'label' => $category->nodeValue,
      ];
    }
  }
  else {
    $categoryCollection = new Collection\Category();
  }
  $this->data['categories'] = $categoryCollection;
  return $this->data['categories'];
}