You are here

public function MigrateSourceJSON::getNextSource in Migrate 7.2

Advances the reader to the next source from source_urls

Return value

bool TRUE if a valid source was loaded

1 call to MigrateSourceJSON::getNextSource()
MigrateSourceJSON::getNextRow in plugins/sources/json.inc
Implementation of MigrationSource::getNextRow().

File

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

Class

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

Code

public function getNextSource() {
  migrate_instrument_start('MigrateSourceJSON::nextSource');

  // Return value
  $status = FALSE;
  while ($this->activeUrl === NULL || count($this->sourceUrls) - 1 > $this->activeUrl) {
    if (is_null($this->activeUrl)) {
      $this->activeUrl = 0;
    }
    else {

      // Increment the activeUrl so we try to load the next source
      $this->activeUrl = $this->activeUrl + 1;
    }
    variable_set('migrate_source_json_active_url', $this->activeUrl);
    $this->reader = new $this->readerClass($this->sourceUrls[$this->activeUrl], $this->idField);
    $this->reader
      ->rewind();
    if ($this->reader
      ->valid()) {

      // We have a valid source
      $status = TRUE;
      break;
    }
  }
  if (count($this->sourceUrls) - 1 == $this->activeUrl) {
    variable_del('migrate_source_json_active_url');
  }
  migrate_instrument_stop('MigrateSourceJSON::nextSource');
  return $status;
}