public function FeedImportVectorReader::map in Feed Import 7.3
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/
inc/ feed_import_readers.inc - Here you'll init your reader.
File
- feed_import_base/
inc/ feed_import_abstract.inc, line 214 - This file contains abstract classes and interfaces for feed import.
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.
Code
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);
}