You are here

abstract class AbstractFeed in Zircon Profile 8

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

Hierarchy

Expanded class hierarchy of AbstractFeed

File

vendor/zendframework/zend-feed/src/Reader/Extension/AbstractFeed.php, line 16

Namespace

Zend\Feed\Reader\Extension
View source
abstract class AbstractFeed {

  /**
   * Parsed feed data
   *
   * @var array
   */
  protected $data = [];

  /**
   * Parsed feed data in the shape of a DOMDocument
   *
   * @var DOMDocument
   */
  protected $domDocument = null;

  /**
   * The base XPath query used to retrieve feed data
   *
   * @var DOMXPath
   */
  protected $xpath = null;

  /**
   * The XPath prefix
   *
   * @var string
   */
  protected $xpathPrefix = '';

  /**
   * Set the DOM document
   *
   * @param  DOMDocument $dom
   * @return AbstractFeed
   */
  public function setDomDocument(DOMDocument $dom) {
    $this->domDocument = $dom;
    return $this;
  }

  /**
   * Get the DOM
   *
   * @return DOMDocument
   */
  public function getDomDocument() {
    return $this->domDocument;
  }

  /**
   * Get the Feed's encoding
   *
   * @return string
   */
  public function getEncoding() {
    $assumed = $this
      ->getDomDocument()->encoding;
    return $assumed;
  }

  /**
   * Set the feed type
   *
   * @param  string $type
   * @return AbstractFeed
   */
  public function setType($type) {
    $this->data['type'] = $type;
    return $this;
  }

  /**
   * Get the feed type
   *
   * If null, it will attempt to autodetect the type.
   *
   * @return string
   */
  public function getType() {
    $type = $this->data['type'];
    if (null === $type) {
      $type = Reader\Reader::detectType($this
        ->getDomDocument());
      $this
        ->setType($type);
    }
    return $type;
  }

  /**
   * Return the feed as an array
   *
   * @return array
   */
  public function toArray() {
    return $this->data;
  }

  /**
   * Set the XPath query
   *
   * @param  DOMXPath $xpath
   * @return AbstractEntry
   */
  public function setXpath(DOMXPath $xpath = null) {
    if (null === $xpath) {
      $this->xpath = null;
      return $this;
    }
    $this->xpath = $xpath;
    $this
      ->registerNamespaces();
    return $this;
  }

  /**
   * Get the DOMXPath object
   *
   * @return string
   */
  public function getXpath() {
    if (null === $this->xpath) {
      $this
        ->setXpath(new DOMXPath($this
        ->getDomDocument()));
    }
    return $this->xpath;
  }

  /**
   * Get the XPath prefix
   *
   * @return string
   */
  public function getXpathPrefix() {
    return $this->xpathPrefix;
  }

  /**
   * Set the XPath prefix
   *
   * @param string $prefix
   * @return void
   */
  public function setXpathPrefix($prefix) {
    $this->xpathPrefix = $prefix;
  }

  /**
   * Register the default namespaces for the current feed format
   */
  protected abstract function registerNamespaces();

}

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::$xpath protected property The base XPath query used to retrieve feed data
AbstractFeed::$xpathPrefix protected property The XPath prefix
AbstractFeed::getDomDocument public function Get the DOM
AbstractFeed::getEncoding public function Get the Feed's encoding
AbstractFeed::getType public function Get the feed type
AbstractFeed::getXpath public function Get the DOMXPath object
AbstractFeed::getXpathPrefix public function Get the XPath prefix
AbstractFeed::registerNamespaces abstract protected function Register the default namespaces for the current feed format
AbstractFeed::setDomDocument public function Set the DOM document
AbstractFeed::setType public function Set the feed type
AbstractFeed::setXpath public function Set the XPath query
AbstractFeed::setXpathPrefix public function Set the XPath prefix
AbstractFeed::toArray public function Return the feed as an array