You are here

public function MigrateItemJSON::getItem in Migrate 6.2

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

Implementors are expected to return an object representing a source item.

Parameters

mixed $id:

Return value

stdClass

Overrides MigrateItem::getItem

File

plugins/sources/json.inc, line 130
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

public function getItem($id) {
  $item_url = $this
    ->constructItemUrl($id);

  // Get the JSON object at the specified URL
  $json = $this
    ->loadJSONUrl($item_url);
  if ($json) {
    return $json;
  }
  else {
    $migration = Migration::currentMigration();
    $message = t('Loading of !objecturl failed:', array(
      '!objecturl' => $item_url,
    ));
    $migration
      ->getMap()
      ->saveMessage(array(
      $id,
    ), $message, MigrationBase::MESSAGE_ERROR);
    return NULL;
  }
}