You are here

public function MigrateSourceJSON::__construct in Migrate 7.2

Source constructor.

Parameters

string or array $url: URL(s) of the JSON source data.

string $id_field: Name of the field within the JSON object holding the ID value.

array $fields: Optional - keys are field names, values are descriptions. Use to override the default descriptions, or to add additional source fields which the migration will add via other means (e.g., prepareRow()).

boolean $options: Options applied to this source. In addition to the standard MigrateSource options, we support:

Overrides MigrateSource::__construct

File

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

Class

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

Code

public function __construct($urls, $id_field, array $fields = array(), array $options = array()) {
  parent::__construct($options);
  $this->idField = $id_field;
  if (empty($options['reader_class'])) {
    $reader_class = 'MigrateJSONReader';
  }
  else {
    $reader_class = $options['reader_class'];
  }
  if (!is_array($urls)) {
    $urls = array(
      $urls,
    );
  }
  $this->sourceUrls = $urls;
  $active_url = variable_get('migrate_source_json_active_url', NULL);
  if (isset($active_url)) {
    $active_url--;
  }
  $this->activeUrl = $active_url;
  $this->readerClass = $reader_class;
  $this->fields = $fields;
}