You are here

abstract class FeedImportDomXPathReader in Feed Import 7.3

This class provides a helper for dom xpath queries.

Hierarchy

Expanded class hierarchy of FeedImportDomXPathReader

File

feed_import_base/inc/feed_import_abstract.inc, line 169
This file contains abstract classes and interfaces for feed import.

View source
abstract class FeedImportDomXPathReader extends FeedImportReader {

  // DomXPath instance
  protected $xpath;

  // Bool, see DomXPath::evaluate
  protected $xpathRegisterNodeNS = TRUE;

  /**
   * {@inheritdoc}
   */
  public function map(&$item, &$path) {
    $values = $this->xpath
      ->evaluate($path, $item, $this->xpathRegisterNodeNS);
    if ($values instanceof DOMNodeList) {
      if (!($len = $values->length)) {
        return NULL;
      }
      elseif ($len == 1) {
        return $values
          ->item(0)->nodeValue;
      }
      $i = 0;
      $ret = array();
      while ($i < $len) {
        $ret[] = $values
          ->item($i++)->nodeValue;
      }
      return $ret;
    }
    return $values;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
FeedImportConfigurable::$options protected property
FeedImportConfigurable::cleanLines public static function Helper function to get lines of a string
FeedImportConfigurable::setOptions public function Sets options for this instance 4
FeedImportDomXPathReader::$xpath protected property
FeedImportDomXPathReader::$xpathRegisterNodeNS protected property
FeedImportDomXPathReader::map public function Returns a value mapped from obj by path. Overrides FeedImportReader::map
FeedImportReader::$items protected property
FeedImportReader::formatPath public function Override this to preprocess your paths before they are used in map(). 2
FeedImportReader::get abstract public function This method returns the next available item or NULL if there are no items left. 6
FeedImportReader::getStreamContext public function Returns a stream context
FeedImportReader::init abstract public function Here you'll init your reader. 6
FeedImportReader::__construct final public function Constructor of reader. Constructor is final but you'll have to implement init() to init your reader.
FeedImportReader::__destruct public function Destructor. 2