You are here

public function MigrateSourceJSON::getNextRow in Migrate 7.2

Implementation of MigrationSource::getNextRow().

Return value

stdClass data for the next row from the JSON source files

File

plugins/sources/json.inc, line 565
Support for migration from JSON sources.

Class

MigrateSourceJSON
Implementation of MigrateSource, to handle imports from stand-alone JSON files.

Code

public function getNextRow() {
  migrate_instrument_start('MigrateSourceJSON::next');
  $row = NULL;

  // The reader is lazy loaded, so it may not be defined yet, need to test if set
  if ($this->reader) {

    // attempt to load the next row
    $this->reader
      ->next();
  }

  // Test the reader for a valid row
  if (isset($this->reader) && $this->reader
    ->valid()) {
    $row = $this->reader
      ->current();
  }
  else {

    // The current source is at the end, try to load the next source
    if ($this
      ->getNextSource()) {
      $row = $this->reader
        ->current();
    }
  }
  migrate_instrument_stop('MigrateSourceJSON::next');
  return $row;
}