public function FeedImportVectorReader::map in Feed Import 8
Returns a value mapped from obj by path.
Parameters
mixed $obj Variable to search:
mixed $path Path to value:
Return value
mixed Mapped value
Overrides FeedImportReader::map
1 call to FeedImportVectorReader::map()
- JSONFIReader::init in feed_import_base/
src/ JSONFIReader.php - Here you'll init your reader.
File
- feed_import_base/
src/ FeedImportVectorReader.php, line 15
Class
- FeedImportVectorReader
- This class is a helper for vector (n dimensions) reader. Path format is like a/b/c which results in [a, b, c] array.
Namespace
Drupal\feed_import_baseCode
public function map(&$vector, &$path) {
$ret = array();
$count = 0;
foreach ($path as $p) {
if (($p = $this
->submap($vector, $p)) !== NULL) {
if ($p instanceof ArrayObject) {
$ret = array_merge($ret, $p
->getArrayCopy());
$count += count($p);
}
else {
$ret[] = $p;
$count++;
}
}
}
return $count == 0 ? NULL : ($count == 1 ? $ret[0] : $ret);
}