You are here

class Entry 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
  2. 8.0 vendor/zendframework/zend-feed/src/Reader/Extension/Content/Entry.php \Zend\Feed\Reader\Extension\Content\Entry
  3. 8.0 vendor/zendframework/zend-feed/src/Reader/Extension/WellFormedWeb/Entry.php \Zend\Feed\Reader\Extension\WellFormedWeb\Entry
  4. 8.0 vendor/zendframework/zend-feed/src/Reader/Extension/Atom/Entry.php \Zend\Feed\Reader\Extension\Atom\Entry
  5. 8.0 vendor/zendframework/zend-feed/src/Reader/Extension/Podcast/Entry.php \Zend\Feed\Reader\Extension\Podcast\Entry
  6. 8.0 vendor/zendframework/zend-feed/src/Reader/Extension/Thread/Entry.php \Zend\Feed\Reader\Extension\Thread\Entry
  7. 8.0 vendor/zendframework/zend-feed/src/Reader/Extension/Slash/Entry.php \Zend\Feed\Reader\Extension\Slash\Entry
  8. 8.0 vendor/zendframework/zend-feed/src/Reader/Extension/DublinCore/Entry.php \Zend\Feed\Reader\Extension\DublinCore\Entry
  9. 8.0 vendor/zendframework/zend-feed/src/Reader/Extension/CreativeCommons/Entry.php \Zend\Feed\Reader\Extension\CreativeCommons\Entry
  10. 8.0 vendor/zendframework/zend-feed/src/Writer/Extension/ITunes/Entry.php \Zend\Feed\Writer\Extension\ITunes\Entry
  11. 8.0 vendor/zendframework/zend-feed/src/Writer/Extension/Content/Renderer/Entry.php \Zend\Feed\Writer\Extension\Content\Renderer\Entry
  12. 8.0 vendor/zendframework/zend-feed/src/Writer/Extension/Threading/Renderer/Entry.php \Zend\Feed\Writer\Extension\Threading\Renderer\Entry
  13. 8.0 vendor/zendframework/zend-feed/src/Writer/Extension/WellFormedWeb/Renderer/Entry.php \Zend\Feed\Writer\Extension\WellFormedWeb\Renderer\Entry
  14. 8.0 vendor/zendframework/zend-feed/src/Writer/Extension/Slash/Renderer/Entry.php \Zend\Feed\Writer\Extension\Slash\Renderer\Entry
  15. 8.0 vendor/zendframework/zend-feed/src/Writer/Extension/DublinCore/Renderer/Entry.php \Zend\Feed\Writer\Extension\DublinCore\Renderer\Entry
  16. 8.0 vendor/zendframework/zend-feed/src/Writer/Extension/ITunes/Renderer/Entry.php \Zend\Feed\Writer\Extension\ITunes\Renderer\Entry
Same name and namespace in other branches
  1. 8 vendor/zendframework/zend-feed/src/Reader/Extension/DublinCore/Entry.php \Zend\Feed\Reader\Extension\DublinCore\Entry

Hierarchy

  • class \Zend\Feed\Reader\Extension\DublinCore\Entry extends \Extension\AbstractEntry

Expanded class hierarchy of Entry

2 string references to 'Entry'
core.services.yml in core/core.services.yml
core/core.services.yml
ExtensionPluginManager::validatePlugin in vendor/zendframework/zend-feed/src/Writer/ExtensionPluginManager.php
Validate the plugin
1 service uses Entry
feed.reader.dublincoreentry in core/core.services.yml
Zend\Feed\Reader\Extension\DublinCore\Entry

File

vendor/zendframework/zend-feed/src/Reader/Extension/DublinCore/Entry.php, line 17

Namespace

Zend\Feed\Reader\Extension\DublinCore
View source
class Entry extends Extension\AbstractEntry {

  /**
   * Get an author entry
   *
   * @param int $index
   * @return string
   */
  public function getAuthor($index = 0) {
    $authors = $this
      ->getAuthors();
    if (isset($authors[$index])) {
      return $authors[$index];
    }
    return;
  }

  /**
   * Get an array with feed authors
   *
   * @return array
   */
  public function getAuthors() {
    if (array_key_exists('authors', $this->data)) {
      return $this->data['authors'];
    }
    $authors = [];
    $list = $this
      ->getXpath()
      ->evaluate($this
      ->getXpathPrefix() . '//dc11:creator');
    if (!$list->length) {
      $list = $this
        ->getXpath()
        ->evaluate($this
        ->getXpathPrefix() . '//dc10:creator');
    }
    if (!$list->length) {
      $list = $this
        ->getXpath()
        ->evaluate($this
        ->getXpathPrefix() . '//dc11:publisher');
      if (!$list->length) {
        $list = $this
          ->getXpath()
          ->evaluate($this
          ->getXpathPrefix() . '//dc10:publisher');
      }
    }
    if ($list->length) {
      foreach ($list as $author) {
        $authors[] = [
          'name' => $author->nodeValue,
        ];
      }
      $authors = new Collection\Author(Reader\Reader::arrayUnique($authors));
    }
    else {
      $authors = null;
    }
    $this->data['authors'] = $authors;
    return $this->data['authors'];
  }

  /**
   * Get categories (subjects under DC)
   *
   * @return Collection\Category
   */
  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'];
  }

  /**
   * Get the entry content
   *
   * @return string
   */
  public function getContent() {
    return $this
      ->getDescription();
  }

  /**
   * Get the entry description
   *
   * @return string
   */
  public function getDescription() {
    if (array_key_exists('description', $this->data)) {
      return $this->data['description'];
    }
    $description = $this
      ->getXpath()
      ->evaluate('string(' . $this
      ->getXpathPrefix() . '/dc11:description)');
    if (!$description) {
      $description = $this
        ->getXpath()
        ->evaluate('string(' . $this
        ->getXpathPrefix() . '/dc10:description)');
    }
    if (!$description) {
      $description = null;
    }
    $this->data['description'] = $description;
    return $this->data['description'];
  }

  /**
   * Get the entry ID
   *
   * @return string
   */
  public function getId() {
    if (array_key_exists('id', $this->data)) {
      return $this->data['id'];
    }
    $id = $this
      ->getXpath()
      ->evaluate('string(' . $this
      ->getXpathPrefix() . '/dc11:identifier)');
    if (!$id) {
      $id = $this
        ->getXpath()
        ->evaluate('string(' . $this
        ->getXpathPrefix() . '/dc10:identifier)');
    }
    $this->data['id'] = $id;
    return $this->data['id'];
  }

  /**
   * Get the entry title
   *
   * @return string
   */
  public function getTitle() {
    if (array_key_exists('title', $this->data)) {
      return $this->data['title'];
    }
    $title = $this
      ->getXpath()
      ->evaluate('string(' . $this
      ->getXpathPrefix() . '/dc11:title)');
    if (!$title) {
      $title = $this
        ->getXpath()
        ->evaluate('string(' . $this
        ->getXpathPrefix() . '/dc10:title)');
    }
    if (!$title) {
      $title = null;
    }
    $this->data['title'] = $title;
    return $this->data['title'];
  }

  /**
   *
   *
   * @return DateTime|null
   */
  public function getDate() {
    if (array_key_exists('date', $this->data)) {
      return $this->data['date'];
    }
    $d = null;
    $date = $this
      ->getXpath()
      ->evaluate('string(' . $this
      ->getXpathPrefix() . '/dc11:date)');
    if (!$date) {
      $date = $this
        ->getXpath()
        ->evaluate('string(' . $this
        ->getXpathPrefix() . '/dc10:date)');
    }
    if ($date) {
      $d = new DateTime($date);
    }
    $this->data['date'] = $d;
    return $this->data['date'];
  }

  /**
   * Register DC namespaces
   *
   * @return void
   */
  protected function registerNamespaces() {
    $this
      ->getXpath()
      ->registerNamespace('dc10', 'http://purl.org/dc/elements/1.0/');
    $this
      ->getXpath()
      ->registerNamespace('dc11', 'http://purl.org/dc/elements/1.1/');
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Entry::getAuthor public function Get an author entry
Entry::getAuthors public function Get an array with feed authors
Entry::getCategories public function Get categories (subjects under DC)
Entry::getContent public function Get the entry content
Entry::getDate public function
Entry::getDescription public function Get the entry description
Entry::getId public function Get the entry ID
Entry::getTitle public function Get the entry title
Entry::registerNamespaces protected function Register DC namespaces