You are here

protected function MigrateItemJSON::loadJSONUrl in Migrate 6.2

Same name and namespace in other branches
  1. 7.2 plugins/sources/json.inc \MigrateItemJSON::loadJSONUrl()

Default JSON loader - just pull and decode. This can be overridden for preprocessing of JSON (removal of unwanted elements, caching of JSON if the source service is slow, etc.)

1 call to MigrateItemJSON::loadJSONUrl()
MigrateItemJSON::getItem in plugins/sources/json.inc
Implementors are expected to return an object representing a source item.

File

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

Class

MigrateItemJSON
Implementation of MigrateItem, for retrieving a parsed JSON object given an ID provided by a MigrateList class.

Code

protected function loadJSONUrl($item_url) {
  if (empty($this->httpOptions)) {
    $json = file_get_contents($item_url);
  }
  else {
    $response = drupal_http_request($item_url, $this->httpOptions);
    $json = $response->data;
  }
  return json_decode($json);
}