You are here

abstract class FeedImportReader in Feed Import 7.3

Abstract implementation of reader.

Hierarchy

Expanded class hierarchy of FeedImportReader

1 string reference to 'FeedImportReader'
feed_import_feed_import_setting_types in ./feed_import.module
Implements hook_feed_import_setting_types().

File

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

View source
abstract class FeedImportReader extends FeedImportConfigurable {

  // Used to store items.
  protected $items = array();

  /**
   * Constructor of reader. Constructor is final but you'll have to
   * implement init() to init your reader.
   *
   * @param array $options An array of options to pass to reader
   */
  public final function __construct(array $options = array()) {
    $this
      ->setOptions($options);
  }

  /**
   * Destructor.
   */
  public function __destruct() {
    unset($this->items, $this->options);
  }

  /**
   * Here you'll init your reader.
   */
  public abstract function init();

  /**
   * This method returns the next available item or NULL if there are no items
   * left.
   *
   * @return mixed The read item
   */
  public abstract function get();

  /**
   * Returns a value mapped from obj by path.
   *
   * @param mixed $obj  Variable to search
   * @param mixed $path Path to value
   *
   * @return mixed Mapped value
   */
  public abstract function map(&$obj, &$path);

  /**
   * Override this to preprocess your paths before they are used in map().
   *
   * @param string $path Path to format
   *
   * @return mixed Formatted path
   */
  public function formatPath($path) {
    return $path;
  }

  /**
   * Returns a stream context
   *
   * @param mixed $ctx
   *    Context options
   *
   * @return resource
   *    Stream context or NULL on failure
   */
  public function getStreamContext($ctx) {
    if ($ctx && (is_array($ctx) || is_scalar($ctx) && ($ctx = json_decode($ctx, TRUE)))) {
      return stream_context_create($ctx);
    }
    return NULL;
  }

}

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
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::map abstract public function Returns a value mapped from obj by path. 4
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