You are here

class Atom in Zircon Profile 8.0

Same name in this branch
  1. 8.0 vendor/zendframework/zend-feed/src/Reader/Entry/Atom.php \Zend\Feed\Reader\Entry\Atom
  2. 8.0 vendor/zendframework/zend-feed/src/Reader/Feed/Atom.php \Zend\Feed\Reader\Feed\Atom
  3. 8.0 vendor/zendframework/zend-feed/src/Writer/Renderer/Entry/Atom.php \Zend\Feed\Writer\Renderer\Entry\Atom
  4. 8.0 vendor/zendframework/zend-feed/src/Writer/Renderer/Feed/Atom.php \Zend\Feed\Writer\Renderer\Feed\Atom
Same name and namespace in other branches
  1. 8 vendor/zendframework/zend-feed/src/Reader/Entry/Atom.php \Zend\Feed\Reader\Entry\Atom

Hierarchy

Expanded class hierarchy of Atom

3 string references to 'Atom'
Feed::export in vendor/zendframework/zend-feed/src/Writer/Feed.php
Attempt to build and return the feed resulting from the data set
Reader::registerCoreExtensions in vendor/zendframework/zend-feed/src/Reader/Reader.php
Register core (default) extensions
Writer::registerCoreExtensions in vendor/zendframework/zend-feed/src/Writer/Writer.php
Register core (default) extensions

File

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

Namespace

Zend\Feed\Reader\Entry
View source
class Atom extends AbstractEntry implements EntryInterface {

  /**
   * XPath query
   *
   * @var string
   */
  protected $xpathQuery = '';

  /**
   * Constructor
   *
   * @param  DOMElement $entry
   * @param  int $entryKey
   * @param  string $type
   */
  public function __construct(DOMElement $entry, $entryKey, $type = null) {
    parent::__construct($entry, $entryKey, $type);

    // Everyone by now should know XPath indices start from 1 not 0
    $this->xpathQuery = '//atom:entry[' . ($this->entryKey + 1) . ']';
    $manager = Reader\Reader::getExtensionManager();
    $extensions = [
      'Atom\\Entry',
      'Thread\\Entry',
      'DublinCore\\Entry',
    ];
    foreach ($extensions as $name) {
      $extension = $manager
        ->get($name);
      $extension
        ->setEntryElement($entry);
      $extension
        ->setEntryKey($entryKey);
      $extension
        ->setType($type);
      $this->extensions[$name] = $extension;
    }
  }

  /**
   * Get the specified author
   *
   * @param  int $index
   * @return string|null
   */
  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'];
    }
    $people = $this
      ->getExtension('Atom')
      ->getAuthors();
    $this->data['authors'] = $people;
    return $this->data['authors'];
  }

  /**
   * Get the entry content
   *
   * @return string
   */
  public function getContent() {
    if (array_key_exists('content', $this->data)) {
      return $this->data['content'];
    }
    $content = $this
      ->getExtension('Atom')
      ->getContent();
    $this->data['content'] = $content;
    return $this->data['content'];
  }

  /**
   * Get the entry creation date
   *
   * @return string
   */
  public function getDateCreated() {
    if (array_key_exists('datecreated', $this->data)) {
      return $this->data['datecreated'];
    }
    $dateCreated = $this
      ->getExtension('Atom')
      ->getDateCreated();
    $this->data['datecreated'] = $dateCreated;
    return $this->data['datecreated'];
  }

  /**
   * Get the entry modification date
   *
   * @return string
   */
  public function getDateModified() {
    if (array_key_exists('datemodified', $this->data)) {
      return $this->data['datemodified'];
    }
    $dateModified = $this
      ->getExtension('Atom')
      ->getDateModified();
    $this->data['datemodified'] = $dateModified;
    return $this->data['datemodified'];
  }

  /**
   * Get the entry description
   *
   * @return string
   */
  public function getDescription() {
    if (array_key_exists('description', $this->data)) {
      return $this->data['description'];
    }
    $description = $this
      ->getExtension('Atom')
      ->getDescription();
    $this->data['description'] = $description;
    return $this->data['description'];
  }

  /**
   * Get the entry enclosure
   *
   * @return string
   */
  public function getEnclosure() {
    if (array_key_exists('enclosure', $this->data)) {
      return $this->data['enclosure'];
    }
    $enclosure = $this
      ->getExtension('Atom')
      ->getEnclosure();
    $this->data['enclosure'] = $enclosure;
    return $this->data['enclosure'];
  }

  /**
   * Get the entry ID
   *
   * @return string
   */
  public function getId() {
    if (array_key_exists('id', $this->data)) {
      return $this->data['id'];
    }
    $id = $this
      ->getExtension('Atom')
      ->getId();
    $this->data['id'] = $id;
    return $this->data['id'];
  }

  /**
   * Get a specific link
   *
   * @param  int $index
   * @return string
   */
  public function getLink($index = 0) {
    if (!array_key_exists('links', $this->data)) {
      $this
        ->getLinks();
    }
    if (isset($this->data['links'][$index])) {
      return $this->data['links'][$index];
    }
    return;
  }

  /**
   * Get all links
   *
   * @return array
   */
  public function getLinks() {
    if (array_key_exists('links', $this->data)) {
      return $this->data['links'];
    }
    $links = $this
      ->getExtension('Atom')
      ->getLinks();
    $this->data['links'] = $links;
    return $this->data['links'];
  }

  /**
   * Get a permalink to the entry
   *
   * @return string
   */
  public function getPermalink() {
    return $this
      ->getLink(0);
  }

  /**
   * Get the entry title
   *
   * @return string
   */
  public function getTitle() {
    if (array_key_exists('title', $this->data)) {
      return $this->data['title'];
    }
    $title = $this
      ->getExtension('Atom')
      ->getTitle();
    $this->data['title'] = $title;
    return $this->data['title'];
  }

  /**
   * Get the number of comments/replies for current entry
   *
   * @return int
   */
  public function getCommentCount() {
    if (array_key_exists('commentcount', $this->data)) {
      return $this->data['commentcount'];
    }
    $commentcount = $this
      ->getExtension('Thread')
      ->getCommentCount();
    if (!$commentcount) {
      $commentcount = $this
        ->getExtension('Atom')
        ->getCommentCount();
    }
    $this->data['commentcount'] = $commentcount;
    return $this->data['commentcount'];
  }

  /**
   * Returns a URI pointing to the HTML page where comments can be made on this entry
   *
   * @return string
   */
  public function getCommentLink() {
    if (array_key_exists('commentlink', $this->data)) {
      return $this->data['commentlink'];
    }
    $commentlink = $this
      ->getExtension('Atom')
      ->getCommentLink();
    $this->data['commentlink'] = $commentlink;
    return $this->data['commentlink'];
  }

  /**
   * Returns a URI pointing to a feed of all comments for this entry
   *
   * @return string
   */
  public function getCommentFeedLink() {
    if (array_key_exists('commentfeedlink', $this->data)) {
      return $this->data['commentfeedlink'];
    }
    $commentfeedlink = $this
      ->getExtension('Atom')
      ->getCommentFeedLink();
    $this->data['commentfeedlink'] = $commentfeedlink;
    return $this->data['commentfeedlink'];
  }

  /**
   * Get category data as a Reader\Reader_Collection_Category object
   *
   * @return Reader\Collection\Category
   */
  public function getCategories() {
    if (array_key_exists('categories', $this->data)) {
      return $this->data['categories'];
    }
    $categoryCollection = $this
      ->getExtension('Atom')
      ->getCategories();
    if (count($categoryCollection) == 0) {
      $categoryCollection = $this
        ->getExtension('DublinCore')
        ->getCategories();
    }
    $this->data['categories'] = $categoryCollection;
    return $this->data['categories'];
  }

  /**
   * Get source feed metadata from the entry
   *
   * @return Reader\Feed\Atom\Source|null
   */
  public function getSource() {
    if (array_key_exists('source', $this->data)) {
      return $this->data['source'];
    }
    $source = $this
      ->getExtension('Atom')
      ->getSource();
    $this->data['source'] = $source;
    return $this->data['source'];
  }

  /**
   * Set the XPath query (incl. on all Extensions)
   *
   * @param DOMXPath $xpath
   * @return void
   */
  public function setXpath(DOMXPath $xpath) {
    parent::setXpath($xpath);
    foreach ($this->extensions as $extension) {
      $extension
        ->setXpath($this->xpath);
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AbstractEntry::$data protected property Feed entry data
AbstractEntry::$domDocument protected property DOM document object
AbstractEntry::$entry protected property Entry instance
AbstractEntry::$entryKey protected property Pointer to the current entry
AbstractEntry::$extensions protected property Registered extensions
AbstractEntry::$xpath protected property XPath object
AbstractEntry::getDomDocument public function Get the DOM
AbstractEntry::getElement public function Get the entry element
AbstractEntry::getEncoding public function Get the Entry's encoding
AbstractEntry::getExtension public function Return an Extension object with the matching name (postfixed with _Entry)
AbstractEntry::getExtensions public function Get registered extensions
AbstractEntry::getType public function Get the entry type
AbstractEntry::getXpath public function Get the XPath query object
AbstractEntry::loadExtensions protected function Load extensions from Zend\Feed\Reader\Reader
AbstractEntry::saveXml public function Get entry as xml
AbstractEntry::__call public function Method overloading: call given method on first extension implementing it
Atom::$xpathQuery protected property XPath query
Atom::getAuthor public function Get the specified author Overrides EntryInterface::getAuthor
Atom::getAuthors public function Get an array with feed authors Overrides EntryInterface::getAuthors
Atom::getCategories public function Get category data as a Reader\Reader_Collection_Category object Overrides EntryInterface::getCategories
Atom::getCommentCount public function Get the number of comments/replies for current entry Overrides EntryInterface::getCommentCount
Atom::getCommentFeedLink public function Returns a URI pointing to a feed of all comments for this entry Overrides EntryInterface::getCommentFeedLink
Atom::getCommentLink public function Returns a URI pointing to the HTML page where comments can be made on this entry Overrides EntryInterface::getCommentLink
Atom::getContent public function Get the entry content Overrides EntryInterface::getContent
Atom::getDateCreated public function Get the entry creation date Overrides EntryInterface::getDateCreated
Atom::getDateModified public function Get the entry modification date Overrides EntryInterface::getDateModified
Atom::getDescription public function Get the entry description Overrides EntryInterface::getDescription
Atom::getEnclosure public function Get the entry enclosure Overrides EntryInterface::getEnclosure
Atom::getId public function Get the entry ID Overrides EntryInterface::getId
Atom::getLink public function Get a specific link Overrides EntryInterface::getLink
Atom::getLinks public function Get all links Overrides EntryInterface::getLinks
Atom::getPermalink public function Get a permalink to the entry Overrides EntryInterface::getPermalink
Atom::getSource public function Get source feed metadata from the entry
Atom::getTitle public function Get the entry title Overrides EntryInterface::getTitle
Atom::setXpath public function Set the XPath query (incl. on all Extensions) Overrides AbstractEntry::setXpath
Atom::__construct public function Constructor Overrides AbstractEntry::__construct