protected function Json::getSourceIterator in Migrate Plus 8
Get the source data for reading.
Parameters
string $url: The URL to read the source data from.
Return value
\RecursiveIteratorIterator|resource
Throws
\Drupal\migrate\MigrateException
1 call to Json::getSourceIterator()
- Json::getSourceData in src/
Plugin/ migrate_plus/ data_parser/ Json.php
File
- src/
Plugin/ migrate_plus/ data_parser/ Json.php, line 136 - Contains Drupal\migrate_plus\Plugin\migrate_plus\data_parser\JSON.
Class
- Json
- Obtain JSON data for migration.
Namespace
Drupal\migrate_plus\Plugin\migrate_plus\data_parserCode
protected function getSourceIterator($url) {
try {
$response = $this
->getDataFetcherPlugin()
->getResponseContent($url);
// The TRUE setting means decode the response into an associative array.
$array = json_decode($response, TRUE);
// Return the results in a recursive iterator that
// can traverse multidimensional arrays.
return new \RecursiveIteratorIterator(new \RecursiveArrayIterator($array), \RecursiveIteratorIterator::SELF_FIRST);
} catch (RequestException $e) {
throw new MigrateException($e
->getMessage(), $e
->getCode(), $e);
}
}