protected function Json::selectByDepth in Migrate Plus 8.3
Same name and namespace in other branches
- 8.5 src/Plugin/migrate_plus/data_parser/Json.php \Drupal\migrate_plus\Plugin\migrate_plus\data_parser\Json::selectByDepth()
- 8.2 src/Plugin/migrate_plus/data_parser/Json.php \Drupal\migrate_plus\Plugin\migrate_plus\data_parser\Json::selectByDepth()
- 8.4 src/Plugin/migrate_plus/data_parser/Json.php \Drupal\migrate_plus\Plugin\migrate_plus\data_parser\Json::selectByDepth()
Get the source data for reading.
Parameters
array $raw_data: Raw data from the JSON feed.
Return value
array Selected items at the requested depth of the JSON feed.
1 call to Json::selectByDepth()
- Json::getSourceData in src/
Plugin/ migrate_plus/ data_parser/ Json.php - Retrieves the JSON data and returns it as an array.
File
- src/
Plugin/ migrate_plus/ data_parser/ Json.php, line 80
Class
- Json
- Obtain JSON data for migration.
Namespace
Drupal\migrate_plus\Plugin\migrate_plus\data_parserCode
protected function selectByDepth(array $raw_data) {
// Return the results in a recursive iterator that can traverse
// multidimensional arrays.
$iterator = new \RecursiveIteratorIterator(new \RecursiveArrayIterator($raw_data), \RecursiveIteratorIterator::SELF_FIRST);
$items = [];
// Backwards-compatibility - an integer item_selector is interpreted as a
// depth. When there is an array of items at the expected depth, pull that
// array out as a distinct item.
$identifierDepth = $this->itemSelector;
$iterator
->rewind();
while ($iterator
->valid()) {
$item = $iterator
->current();
if (is_array($item) && $iterator
->getDepth() == $identifierDepth) {
$items[] = $item;
}
$iterator
->next();
}
return $items;
}