You are here

protected function Json::getSourceData in Migrate Plus 8

Same name and namespace in other branches
  1. 8.5 src/Plugin/migrate_plus/data_parser/Json.php \Drupal\migrate_plus\Plugin\migrate_plus\data_parser\Json::getSourceData()
  2. 8.2 src/Plugin/migrate_plus/data_parser/Json.php \Drupal\migrate_plus\Plugin\migrate_plus\data_parser\Json::getSourceData()
  3. 8.3 src/Plugin/migrate_plus/data_parser/Json.php \Drupal\migrate_plus\Plugin\migrate_plus\data_parser\Json::getSourceData()
  4. 8.4 src/Plugin/migrate_plus/data_parser/Json.php \Drupal\migrate_plus\Plugin\migrate_plus\data_parser\Json::getSourceData()
1 call to Json::getSourceData()
Json::openSourceUrl in src/Plugin/migrate_plus/data_parser/Json.php
Opens the specified URL.

File

src/Plugin/migrate_plus/data_parser/Json.php, line 109
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_parser

Code

protected function getSourceData($url) {
  $iterator = $this
    ->getSourceIterator($url);

  // Recurse through the result array. When there is an array of items at the
  // expected depth, pull that array out as a distinct item.
  $identifierDepth = $this->itemSelector;
  $items = [];
  while ($iterator
    ->valid()) {
    $iterator
      ->next();
    $item = $iterator
      ->current();
    if (is_array($item) && $iterator
      ->getDepth() == $identifierDepth) {
      $items[] = $item;
    }
  }
  return $items;
}