abstract class FeedImportUniVectorReader in Feed Import 8
This class is a helper for unidimensional vector reader. This can be used for CSV, SQL results, etc.
Hierarchy
- class \Drupal\feed_import_base\FeedImportConfigurable
- class \Drupal\feed_import_base\FeedImportReader
- class \Drupal\feed_import_base\FeedImportUniVectorReader
- class \Drupal\feed_import_base\FeedImportReader
Expanded class hierarchy of FeedImportUniVectorReader
File
- feed_import_base/
src/ FeedImportUniVectorReader.php, line 8
Namespace
Drupal\feed_import_baseView source
abstract class FeedImportUniVectorReader extends FeedImportReader {
/**
* {@inheritdoc}
*/
public function map(&$vector, &$path) {
if (is_array($vector)) {
$count = 0;
$ret = array();
foreach ($path as $p) {
if (isset($vector[$p])) {
$ret[] = $vector[$p];
$count++;
}
}
return $count == 0 ? NULL : ($count == 1 ? $ret[0] : $ret);
}
elseif (is_object($vector)) {
$count = 0;
$ret = array();
foreach ($path as $p) {
if (isset($vector->{$p})) {
$ret[] = $vector->{$p};
$count++;
}
}
return $count == 0 ? NULL : ($count == 1 ? $ret[0] : $ret);
}
return NULL;
}
/**
* {@inheritdoc}
*/
public function formatPath($path) {
return preg_split('/(\\s?\\|\\s?)/', $path, -1, PREG_SPLIT_NO_EMPTY);
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FeedImportConfigurable:: |
protected | property | ||
FeedImportConfigurable:: |
public static | function | Helper function to get lines of a string | |
FeedImportConfigurable:: |
public | function | Sets options for this instance | 4 |
FeedImportReader:: |
protected | property | ||
FeedImportReader:: |
abstract public | function | This method returns the next available item or NULL if there are no items left. | 6 |
FeedImportReader:: |
public | function | Returns a stream context | |
FeedImportReader:: |
abstract public | function | Here you'll init your reader. | 6 |
FeedImportReader:: |
final public | function | Constructor of reader. Constructor is final but you'll have to implement init() to init your reader. | |
FeedImportReader:: |
public | function | Destructor. | 2 |
FeedImportUniVectorReader:: |
public | function |
Override this to preprocess your paths before they are used in map(). Overrides FeedImportReader:: |
1 |
FeedImportUniVectorReader:: |
public | function |
Returns a value mapped from obj by path. Overrides FeedImportReader:: |