abstract class AbstractFeed in Zircon Profile 8
Same name in this branch
- 8 vendor/zendframework/zend-feed/src/Reader/AbstractFeed.php \Zend\Feed\Reader\AbstractFeed
- 8 vendor/zendframework/zend-feed/src/Writer/AbstractFeed.php \Zend\Feed\Writer\AbstractFeed
- 8 vendor/zendframework/zend-feed/src/Reader/Extension/AbstractFeed.php \Zend\Feed\Reader\Extension\AbstractFeed
- 8 vendor/zendframework/zend-feed/src/Reader/Feed/AbstractFeed.php \Zend\Feed\Reader\Feed\AbstractFeed
Same name and namespace in other branches
- 8.0 vendor/zendframework/zend-feed/src/Reader/Feed/AbstractFeed.php \Zend\Feed\Reader\Feed\AbstractFeed
Hierarchy
- class \Zend\Feed\Reader\Feed\AbstractFeed implements FeedInterface
Expanded class hierarchy of AbstractFeed
File
- vendor/
zendframework/ zend-feed/ src/ Reader/ Feed/ AbstractFeed.php, line 20
Namespace
Zend\Feed\Reader\FeedView source
abstract class AbstractFeed implements FeedInterface {
/**
* Parsed feed data
*
* @var array
*/
protected $data = [];
/**
* Parsed feed data in the shape of a DOMDocument
*
* @var DOMDocument
*/
protected $domDocument = null;
/**
* An array of parsed feed entries
*
* @var array
*/
protected $entries = [];
/**
* A pointer for the iterator to keep track of the entries array
*
* @var int
*/
protected $entriesKey = 0;
/**
* The base XPath query used to retrieve feed data
*
* @var DOMXPath
*/
protected $xpath = null;
/**
* Array of loaded extensions
*
* @var array
*/
protected $extensions = [];
/**
* Original Source URI (set if imported from a URI)
*
* @var string
*/
protected $originalSourceUri = null;
/**
* Constructor
*
* @param DOMDocument $domDocument The DOM object for the feed's XML
* @param string $type Feed type
*/
public function __construct(DOMDocument $domDocument, $type = null) {
$this->domDocument = $domDocument;
$this->xpath = new DOMXPath($this->domDocument);
if ($type !== null) {
$this->data['type'] = $type;
}
else {
$this->data['type'] = Reader\Reader::detectType($this->domDocument);
}
$this
->registerNamespaces();
$this
->indexEntries();
$this
->loadExtensions();
}
/**
* 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.
*
* @param string $uri
*/
public function setOriginalSourceUri($uri) {
$this->originalSourceUri = $uri;
}
/**
* Get an original source URI for the feed being parsed. Returns null if
* unset or the feed was not imported from a URI.
*
* @return string|null
*/
public function getOriginalSourceUri() {
return $this->originalSourceUri;
}
/**
* Get the number of feed entries.
* Required by the Iterator interface.
*
* @return int
*/
public function count() {
return count($this->entries);
}
/**
* Return the current entry
*
* @return \Zend\Feed\Reader\Entry\EntryInterface
*/
public function current() {
if (substr($this
->getType(), 0, 3) == 'rss') {
$reader = new Reader\Entry\Rss($this->entries[$this
->key()], $this
->key(), $this
->getType());
}
else {
$reader = new Reader\Entry\Atom($this->entries[$this
->key()], $this
->key(), $this
->getType());
}
$reader
->setXpath($this->xpath);
return $reader;
}
/**
* 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;
if (empty($assumed)) {
$assumed = 'UTF-8';
}
return $assumed;
}
/**
* Get feed as xml
*
* @return string
*/
public function saveXml() {
return $this
->getDomDocument()
->saveXml();
}
/**
* Get the DOMElement representing the items/feed element
*
* @return DOMElement
*/
public function getElement() {
return $this
->getDomDocument()->documentElement;
}
/**
* Get the DOMXPath object for this feed
*
* @return DOMXPath
*/
public function getXpath() {
return $this->xpath;
}
/**
* Get the feed type
*
* @return string
*/
public function getType() {
return $this->data['type'];
}
/**
* Return the current feed key
*
* @return int
*/
public function key() {
return $this->entriesKey;
}
/**
* Move the feed pointer forward
*
*/
public function next() {
++$this->entriesKey;
}
/**
* Reset the pointer in the feed object
*
*/
public function rewind() {
$this->entriesKey = 0;
}
/**
* Check to see if the iterator is still valid
*
* @return bool
*/
public function valid() {
return 0 <= $this->entriesKey && $this->entriesKey < $this
->count();
}
public function getExtensions() {
return $this->extensions;
}
public function __call($method, $args) {
foreach ($this->extensions as $extension) {
if (method_exists($extension, $method)) {
return call_user_func_array([
$extension,
$method,
], $args);
}
}
throw new Exception\BadMethodCallException('Method: ' . $method . 'does not exist and could not be located on a registered Extension');
}
/**
* Return an Extension object with the matching name (postfixed with _Feed)
*
* @param string $name
* @return \Zend\Feed\Reader\Extension\AbstractFeed
*/
public function getExtension($name) {
if (array_key_exists($name . '\\Feed', $this->extensions)) {
return $this->extensions[$name . '\\Feed'];
}
return;
}
protected function loadExtensions() {
$all = Reader\Reader::getExtensions();
$manager = Reader\Reader::getExtensionManager();
$feed = $all['feed'];
foreach ($feed as $extension) {
if (in_array($extension, $all['core'])) {
continue;
}
if (!$manager
->has($extension)) {
throw new Exception\RuntimeException(sprintf('Unable to load extension "%s"; cannot find class', $extension));
}
$plugin = $manager
->get($extension);
$plugin
->setDomDocument($this
->getDomDocument());
$plugin
->setType($this->data['type']);
$plugin
->setXpath($this->xpath);
$this->extensions[$extension] = $plugin;
}
}
/**
* Read all entries to the internal entries array
*
*/
protected abstract function indexEntries();
/**
* Register the default namespaces for the current feed format
*
*/
protected abstract function registerNamespaces();
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
AbstractFeed:: |
protected | property | Parsed feed data | |
AbstractFeed:: |
protected | property | Parsed feed data in the shape of a DOMDocument | |
AbstractFeed:: |
protected | property | An array of parsed feed entries | |
AbstractFeed:: |
protected | property | A pointer for the iterator to keep track of the entries array | |
AbstractFeed:: |
protected | property | Array of loaded extensions | |
AbstractFeed:: |
protected | property | Original Source URI (set if imported from a URI) | |
AbstractFeed:: |
protected | property | The base XPath query used to retrieve feed data | |
AbstractFeed:: |
public | function | Get the number of feed entries. Required by the Iterator interface. | |
AbstractFeed:: |
public | function | Return the current entry | |
AbstractFeed:: |
public | function | Get the DOM | |
AbstractFeed:: |
public | function | Get the DOMElement representing the items/feed element | |
AbstractFeed:: |
public | function | Get the Feed's encoding | |
AbstractFeed:: |
public | function | Return an Extension object with the matching name (postfixed with _Feed) | |
AbstractFeed:: |
public | function | ||
AbstractFeed:: |
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:: |
public | function | Get the feed type | |
AbstractFeed:: |
public | function | Get the DOMXPath object for this feed | |
AbstractFeed:: |
abstract protected | function | Read all entries to the internal entries array | 2 |
AbstractFeed:: |
public | function | Return the current feed key | |
AbstractFeed:: |
protected | function | ||
AbstractFeed:: |
public | function | Move the feed pointer forward | |
AbstractFeed:: |
abstract protected | function | Register the default namespaces for the current feed format | 2 |
AbstractFeed:: |
public | function | Reset the pointer in the feed object | |
AbstractFeed:: |
public | function | Get feed as xml | |
AbstractFeed:: |
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:: |
public | function | Check to see if the iterator is still valid | |
AbstractFeed:: |
public | function | ||
AbstractFeed:: |
public | function | Constructor | 2 |
FeedInterface:: |
public | function | Get a single author | 2 |
FeedInterface:: |
public | function | Get an array with feed authors | 2 |
FeedInterface:: |
public | function | Get all categories | 2 |
FeedInterface:: |
public | function | Get the copyright entry | 2 |
FeedInterface:: |
public | function | Get the feed creation date | 2 |
FeedInterface:: |
public | function | Get the feed modification date | 2 |
FeedInterface:: |
public | function | Get the feed description | |
FeedInterface:: |
public | function | Get a link to the XML feed | 2 |
FeedInterface:: |
public | function | Get the feed generator entry | 2 |
FeedInterface:: |
public | function | Get the feed ID | 2 |
FeedInterface:: |
public | function | Get the feed language | 2 |
FeedInterface:: |
public | function | Get a link to the HTML source | 2 |
FeedInterface:: |
public | function | Get the feed title | 2 |