You are here

class Atom in Zircon Profile 8

Same name in this branch
  1. 8 vendor/zendframework/zend-feed/src/Reader/Entry/Atom.php \Zend\Feed\Reader\Entry\Atom
  2. 8 vendor/zendframework/zend-feed/src/Reader/Feed/Atom.php \Zend\Feed\Reader\Feed\Atom
  3. 8 vendor/zendframework/zend-feed/src/Writer/Renderer/Entry/Atom.php \Zend\Feed\Writer\Renderer\Entry\Atom
  4. 8 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.0 vendor/zendframework/zend-feed/src/Reader/Feed/Atom.php \Zend\Feed\Reader\Feed\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/Feed/Atom.php, line 17

Namespace

Zend\Feed\Reader\Feed
View source
class Atom extends AbstractFeed {

  /**
   * Constructor
   *
   * @param  DOMDocument $dom
   * @param  string $type
   */
  public function __construct(DOMDocument $dom, $type = null) {
    parent::__construct($dom, $type);
    $manager = Reader\Reader::getExtensionManager();
    $atomFeed = $manager
      ->get('Atom\\Feed');
    $atomFeed
      ->setDomDocument($dom);
    $atomFeed
      ->setType($this->data['type']);
    $atomFeed
      ->setXpath($this->xpath);
    $this->extensions['Atom\\Feed'] = $atomFeed;
    $atomFeed = $manager
      ->get('DublinCore\\Feed');
    $atomFeed
      ->setDomDocument($dom);
    $atomFeed
      ->setType($this->data['type']);
    $atomFeed
      ->setXpath($this->xpath);
    $this->extensions['DublinCore\\Feed'] = $atomFeed;
    foreach ($this->extensions as $extension) {
      $extension
        ->setXpathPrefix('/atom:feed');
    }
  }

  /**
   * Get a single 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'];
    }
    $authors = $this
      ->getExtension('Atom')
      ->getAuthors();
    $this->data['authors'] = $authors;
    return $this->data['authors'];
  }

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

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

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

  /**
   * Get the feed lastBuild date. This is not implemented in Atom.
   *
   * @return string|null
   */
  public function getLastBuildDate() {
    return;
  }

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

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

  /**
   * Get the feed ID
   *
   * @return string|null
   */
  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 the feed language
   *
   * @return string|null
   */
  public function getLanguage() {
    if (array_key_exists('language', $this->data)) {
      return $this->data['language'];
    }
    $language = $this
      ->getExtension('Atom')
      ->getLanguage();
    if (!$language) {
      $language = $this->xpath
        ->evaluate('string(//@xml:lang[1])');
    }
    if (!$language) {
      $language = null;
    }
    $this->data['language'] = $language;
    return $this->data['language'];
  }

  /**
   * Get a link to the source website
   *
   * @return string|null
   */
  public function getBaseUrl() {
    if (array_key_exists('baseUrl', $this->data)) {
      return $this->data['baseUrl'];
    }
    $baseUrl = $this
      ->getExtension('Atom')
      ->getBaseUrl();
    $this->data['baseUrl'] = $baseUrl;
    return $this->data['baseUrl'];
  }

  /**
   * Get a link to the source website
   *
   * @return string|null
   */
  public function getLink() {
    if (array_key_exists('link', $this->data)) {
      return $this->data['link'];
    }
    $link = $this
      ->getExtension('Atom')
      ->getLink();
    $this->data['link'] = $link;
    return $this->data['link'];
  }

  /**
   * Get feed image data
   *
   * @return array|null
   */
  public function getImage() {
    if (array_key_exists('image', $this->data)) {
      return $this->data['image'];
    }
    $link = $this
      ->getExtension('Atom')
      ->getImage();
    $this->data['image'] = $link;
    return $this->data['image'];
  }

  /**
   * Get a link to the feed's XML Url
   *
   * @return string|null
   */
  public function getFeedLink() {
    if (array_key_exists('feedlink', $this->data)) {
      return $this->data['feedlink'];
    }
    $link = $this
      ->getExtension('Atom')
      ->getFeedLink();
    if ($link === null || empty($link)) {
      $link = $this
        ->getOriginalSourceUri();
    }
    $this->data['feedlink'] = $link;
    return $this->data['feedlink'];
  }

  /**
   * Get the feed title
   *
   * @return string|null
   */
  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 an array of any supported Pusubhubbub endpoints
   *
   * @return array|null
   */
  public function getHubs() {
    if (array_key_exists('hubs', $this->data)) {
      return $this->data['hubs'];
    }
    $hubs = $this
      ->getExtension('Atom')
      ->getHubs();
    $this->data['hubs'] = $hubs;
    return $this->data['hubs'];
  }

  /**
   * Get all categories
   *
   * @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'];
  }

  /**
   * Read all entries to the internal entries array
   *
   * @return void
   */
  protected function indexEntries() {
    if ($this
      ->getType() == Reader\Reader::TYPE_ATOM_10 || $this
      ->getType() == Reader\Reader::TYPE_ATOM_03) {
      $entries = $this->xpath
        ->evaluate('//atom:entry');
      foreach ($entries as $index => $entry) {
        $this->entries[$index] = $entry;
      }
    }
  }

  /**
   * Register the default namespaces for the current feed format
   *
   */
  protected function registerNamespaces() {
    switch ($this->data['type']) {
      case Reader\Reader::TYPE_ATOM_03:
        $this->xpath
          ->registerNamespace('atom', Reader\Reader::NAMESPACE_ATOM_03);
        break;
      case Reader\Reader::TYPE_ATOM_10:
      default:
        $this->xpath
          ->registerNamespace('atom', Reader\Reader::NAMESPACE_ATOM_10);
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AbstractFeed::$data protected property Parsed feed data
AbstractFeed::$domDocument protected property Parsed feed data in the shape of a DOMDocument
AbstractFeed::$entries protected property An array of parsed feed entries
AbstractFeed::$entriesKey protected property A pointer for the iterator to keep track of the entries array
AbstractFeed::$extensions protected property Array of loaded extensions
AbstractFeed::$originalSourceUri protected property Original Source URI (set if imported from a URI)
AbstractFeed::$xpath protected property The base XPath query used to retrieve feed data
AbstractFeed::count public function Get the number of feed entries. Required by the Iterator interface.
AbstractFeed::current public function Return the current entry
AbstractFeed::getDomDocument public function Get the DOM
AbstractFeed::getElement public function Get the DOMElement representing the items/feed element
AbstractFeed::getEncoding public function Get the Feed's encoding
AbstractFeed::getExtension public function Return an Extension object with the matching name (postfixed with _Feed)
AbstractFeed::getExtensions public function
AbstractFeed::getOriginalSourceUri public function Get an original source URI for the feed being parsed. Returns null if unset or the feed was not imported from a URI.
AbstractFeed::getType public function Get the feed type
AbstractFeed::getXpath public function Get the DOMXPath object for this feed
AbstractFeed::key public function Return the current feed key
AbstractFeed::loadExtensions protected function
AbstractFeed::next public function Move the feed pointer forward
AbstractFeed::rewind public function Reset the pointer in the feed object
AbstractFeed::saveXml public function Get feed as xml
AbstractFeed::setOriginalSourceUri public function Set an original source URI for the feed being parsed. This value is returned from getFeedLink() method if the feed does not carry a self-referencing URI.
AbstractFeed::valid public function Check to see if the iterator is still valid
AbstractFeed::__call public function
Atom::getAuthor public function Get a single author Overrides FeedInterface::getAuthor
Atom::getAuthors public function Get an array with feed authors Overrides FeedInterface::getAuthors
Atom::getBaseUrl public function Get a link to the source website
Atom::getCategories public function Get all categories Overrides FeedInterface::getCategories
Atom::getCopyright public function Get the copyright entry Overrides FeedInterface::getCopyright
Atom::getDateCreated public function Get the feed creation date Overrides FeedInterface::getDateCreated
Atom::getDateModified public function Get the feed modification date Overrides FeedInterface::getDateModified
Atom::getDescription public function Get the feed description Overrides FeedInterface::getDescription
Atom::getFeedLink public function Get a link to the feed's XML Url Overrides FeedInterface::getFeedLink
Atom::getGenerator public function Get the feed generator entry Overrides FeedInterface::getGenerator
Atom::getHubs public function Get an array of any supported Pusubhubbub endpoints
Atom::getId public function Get the feed ID Overrides FeedInterface::getId
Atom::getImage public function Get feed image data
Atom::getLanguage public function Get the feed language Overrides FeedInterface::getLanguage
Atom::getLastBuildDate public function Get the feed lastBuild date. This is not implemented in Atom.
Atom::getLink public function Get a link to the source website Overrides FeedInterface::getLink
Atom::getTitle public function Get the feed title Overrides FeedInterface::getTitle
Atom::indexEntries protected function Read all entries to the internal entries array Overrides AbstractFeed::indexEntries
Atom::registerNamespaces protected function Register the default namespaces for the current feed format Overrides AbstractFeed::registerNamespaces
Atom::__construct public function Constructor Overrides AbstractFeed::__construct