FeedImportReader.php in Feed Import 8
Namespace
Drupal\feed_import_baseFile
feed_import_base/src/FeedImportReader.phpView source
<?php
namespace Drupal\feed_import_base;
/**
* Abstract implementation of reader.
*/
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;
}
}
Classes
Name | Description |
---|---|
FeedImportReader | Abstract implementation of reader. |