private function Importer::flattenArray in Feeds Paragraphs 8
1 call to Importer::flattenArray()
- Importer::sliceValues in src/
Importer.php - Slices values.
File
- src/
Importer.php, line 771
Class
Namespace
Drupal\feeds_para_mapperCode
private function flattenArray($arr, $property = null) {
$properties = $this->targetInfo->properties;
if (!is_array($arr)) {
$stop = null;
if (isset($property)) {
return [
$property => $arr,
];
}
}
$items = [];
foreach ($arr as $item) {
if (is_array($item)) {
foreach ($properties as $prop) {
if (array_key_exists($prop, $item)) {
$items = array_merge($items, $this
->flattenArray($item, $prop));
}
elseif (isset($property)) {
$items = array_merge($items, $this
->flattenArray($item, $property));
}
}
}
else {
if (isset($property)) {
$items[] = [
$property => $item,
];
}
else {
$items[] = $item;
}
}
}
return $items;
}