You are here

public function MigrateListJSON::getIdList in Migrate 7.2

Same name and namespace in other branches
  1. 6.2 plugins/sources/json.inc \MigrateListJSON::getIdList()

Load the JSON at the given URL, and return an array of the IDs found within it.

Return value

array

Overrides MigrateList::getIdList

File

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

Class

MigrateListJSON
Implementation of MigrateList, for retrieving a list of IDs to be migrated from a JSON object.

Code

public function getIdList() {
  migrate_instrument_start("Retrieve {$this->listUrl}");
  if (empty($this->httpOptions)) {
    $json = file_get_contents($this->listUrl);
  }
  else {
    $response = drupal_http_request($this->listUrl, $this->httpOptions);
    $json = $response->data;
  }
  migrate_instrument_stop("Retrieve {$this->listUrl}");
  if ($json) {
    $data = drupal_json_decode($json);
    if ($data !== NULL) {
      return $this
        ->getIDsFromJSON($data);
    }
  }
  Migration::displayMessage(t('Loading of !listurl failed:', array(
    '!listurl' => $this->listUrl,
  )));
  return NULL;
}