You are here

public function Entry::getCategories in Zircon Profile 8.0

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

Get all categories

Return value

Collection\Category

File

vendor/zendframework/zend-feed/src/Reader/Extension/Atom/Entry.php, line 487

Class

Entry

Namespace

Zend\Feed\Reader\Extension\Atom

Code

public function getCategories() {
  if (array_key_exists('categories', $this->data)) {
    return $this->data['categories'];
  }
  if ($this
    ->getAtomType() == Reader\Reader::TYPE_ATOM_10) {
    $list = $this
      ->getXpath()
      ->query($this
      ->getXpathPrefix() . '//atom:category');
  }
  else {

    /**
     * Since Atom 0.3 did not support categories, it would have used the
     * Dublin Core extension. However there is a small possibility Atom 0.3
     * may have been retrofitted to use Atom 1.0 instead.
     */
    $this
      ->getXpath()
      ->registerNamespace('atom10', Reader\Reader::NAMESPACE_ATOM_10);
    $list = $this
      ->getXpath()
      ->query($this
      ->getXpathPrefix() . '//atom10:category');
  }
  if ($list->length) {
    $categoryCollection = new Collection\Category();
    foreach ($list as $category) {
      $categoryCollection[] = [
        'term' => $category
          ->getAttribute('term'),
        'scheme' => $category
          ->getAttribute('scheme'),
        'label' => $category
          ->getAttribute('label'),
      ];
    }
  }
  else {
    return new Collection\Category();
  }
  $this->data['categories'] = $categoryCollection;
  return $this->data['categories'];
}